I tried doing exactly that, but the WASM specs are hard for me to grok , and kept expanding over time, so unfortunately I never managed to get something useful. My language kept s-expressions but just made WAT look like a "normal" LISP-like language. I also wanted to have equivalence to the WASM binary format so you could generate any byte code you wanted precisely. Besides being a good target for compiling to WASM, I think that such language could be easily written by hand if it was pleasurable enough, and that would give a much nicer way to write WASM for web application that need performance, or even non-web applications, since once you have a WASM file you can easily run it with several non-browser runtimes as well as just compile to native for tiny binaries. For anything useful, you'll need WASI which is another rabbit hole though. Using AI, anyone can do that now, so I gave up and will just wait for someone else to spend the tokens :D.
This is covered in the article. Author is implementing wasm support for OCaml, needs byte level control over the compilation target, and as a consequence is implementing features in bytecode. This is a semantically equal but less explicit rendering of the existing text format for wasm bytecode.
7
u/simon_o 1d ago
This will certainly be useful for people who felt that dealing with WAT for writing wasm manually was too cumbersome.
I just wish they hadn't faithfully copied over every syntactic paper-cut from Rust.
4
u/imbev 1d ago
Why not https://www.assemblyscript.org/ or Rust with a WASM toolchain?
1
u/lood9phee2Ri 5h ago
Nah, I strongly prefer sexp syntax.