upvote
Tbh I don't understand why people don't like the intermediate representation. It's ridiculously high level compared to say x64 or ARM or even RISC V assembly. It's a simple lisp that most high schoolers who have taken basic programming can read it without issue.

I can't think of a single other production level VM with such an easy to read decompiled form.

reply
People who hate Lisp or hate S-expressions generally won't like WAT. That's what I see in Wax - a Rust lover wants something more Rust-like than Lisp-like.

Lisps are really handy, though, because it's basically textual representation of an AST. Code is data, data is code, and a tree walker with minimal lexing and parsing can interpret the thing through (eval ), compile it, or make transformations to the tree. There's not much hidden semantics in special syntax.

reply
Except this lisp does not come with quoting or eval, and if you want to parse it you’ll probably have an easier time with the bytecode itself.
reply
IR needs a massive compiler to use.
reply
Maybe people don't like it because it's LISPy and practically unreadable?
reply
Well the problem with an alternate syntax like this is that it's not really 1:1 with WAT so it ends up being hard for you easily figure out how to derive an exact WAT form from your starting language. WAX wouldn't eliminate this problem.

What I've been doing is making a simple library that can build WASM instructions in memory which closely follows the syntax and semantics, and using my programming language of choice as basically a preprocessor that provides high level abstractions over raw WAT/WASM. That method is VERY amenable to optimization, either by hand or via LLM. Because you can run your code generation, figure out how the bytecode should change, and work backwards. And if you take care while writing it, it can be very easy to follow the code.

reply
> Well the problem with an alternate syntax like this is that it's not really 1:1 with WAT

The author claims it is so and wax can be converted back and forth with wat or wasm bytecode. Do you have evidence to the contrary?

> What I've been doing is making a simple library that can build WASM instructions in memory which closely follows the syntax and semantics, and using my programming language of choice as basically a preprocessor that provides high level abstractions over raw WAT/WASM.

That is a completely different purpose unrelated to the goals of wax.

reply
> Do you have evidence to the contrary?

What I mean is, you can't effectively steer a high level language to produce some exact sequence of bytecode. It's not "1:1" with what you end up with, it's the nature of the beast. To get that, you have to write in WAT or a higher level WAT generator that you CAN steer.

As a trivial example, `a = 1; a = a + 1` (note: I'm not using this exact language, just speaking in generalities). Will the compiler produce the naive bytecode:

```

(local $a i32)

i32.const 1

local.set $a

local.get $a

i32.const 1

i32.add

local.set $a

```

Or will it perform constant folding and give you:

```

(local $a i32)

i32.const 2

local.set $a

```

Maybe, maybe not. Who knows! Now that's a trivial example obviously, but there's plenty of places where there are optimizations you'd LIKE to happen but have no control over. Which no doubt WAX is susceptible to.

> That is a completely different purpose unrelated to the goals of wax.

But it's the only way to truly shape the end-result bytecode into EXACTLY what you want when starting from a higher level language.

reply