Wax: A User-Friendly Syntax for WebAssembly

64 points by rs86 a day ago on lobsters | 10 comments

andyferris | 14 hours ago

Really cool.

I’m wondering if wit (wasm interface types) could be part of this? You’d start to get towards a higher level language where you can define types, link programs & libraries, and it still transforms bidirectionally with the underlying wasm modules.

Personally I think that could be quite useful!

toastal | 10 hours ago

Overestimates how “friendly” the syntax is 😅. I dare say I find the LISP-y examples easier to read. We are trading paren noise for semicolon noise. It’s sad that Tarides, known for their OCaml work, didn’t make an ML—to which would have been something I did find friendly (but I guess that is what wasm_of_ocaml is trying to do).

masklinn | 9 hours ago

wax is an alternate representation for webassembly bytecode itself. Making an ML would either not work or result in a pretty nonsensical language given the WASM ISA, especially the control flow. That's also the cause of some weird divergences from actual Rust e.g. that blocks have to be labelled, or that loops don't (loop).

nemin | 10 hours ago

I'd love an ML-y syntax as well, because OCaml is delightful, but the rest of your argument reads odd to me. Semicolon noise? This just seems like "Rust, but slightly different". The only part that reads like noise to me is the &? stuff, but I'm sure it's something you get used to.

toastal | 8 hours ago

This assume the user knows & finds Rust pleasant. I’m not in this camp 🤷, & it’s a bit odd me given its maker.

nemin | 7 hours ago

WAT on the other hand assumes the user knows and finds Lisp pleasant and if we had to guess which camp is bigger, I wouldn't be betting on the Lisp fans.

That being said, I'm not trying to yuck your yum, I just think it's pretty clear why they picked a C-ish syntax. Programming as a whole is overwhelmingly Algol-shaped.

This looks delightful! Bravo team! I hope to find some time to play with this in future.

crmsnbleyd | 17 hours ago

Other than the more rust-like syntax, what would cause one to use this over AssemblyScript?

robey | 17 hours ago

I tried AssemblyScript a few years ago, and like it, but I think the goal there is a one-way compilation: the javascript-like syntax compiles down to wasm bytecode.

It looks like the intent of wax is to be a replacement for "wat" (the lisp-like assembly syntax with all the parens) that removes a lot of the boilerplate, but is still bidirectional: you can generate wax from wasm bytecode, and you can generate wasm bytecode from wax, losslessly one-to-one.

Wax is for when you want to write wasm by hand. Wasm is a binary format, so you would want to use a text-based representation of the bytecode instead of using a hex editor or such. Traditionally that was the wat format, now there is this wax format too.

AssemblyScript is a higher level programming language that compiles to wasm. It is not literally wasm, it has different feature and semantics and you cannot convert wasm into AssemblyScript.

Comment removed by its author