Wax: A User-Friendly Syntax for WebAssembly(tarides.com)
208 points by theanonymousone 1 day ago | 53 comments
tl;dr: Wax is a Rust-like syntax for hand-written WebAssembly that compiles 1:1 to Wasm instructions, built by the wasm_of_ocaml team to replace their 27,000-line WAT runtime. It ships with a toolchain that converts bidirectionally between Wax, WAT, and Wasm binary, plus a type checker, formatter, LSP server, and editor integrations that also work on plain .wat files. Unlike C/Rust targeting linear memory, Wax gives precise control over GC-proposal structs, arrays, and references, making it suited for runtime code where every emitted instruction matters.
HN Discussion:
  • ↑The reverse direction (WAT/Wasm to high-level language) is the most valuable feature of Wax
  • ↑WAT's s-expression syntax is genuinely bad and a more readable alternative is overdue
  • ↓S-expressions in WAT are actually user-friendly and enable powerful metaprogramming
  • ↓Wax is redundant since Rust already targets WASM and WAT isn't meant for humans anyway
  • •Comparisons to similar IR-as-language efforts like GIMPLE or hand-written LLVM IR