Wax's concise syntax (left) compiles to the same seven‑byte WebAssembly module as the verbose WAT representation (right).
*Wax offers a Rust‑style surface for writing WebAssembly that compiles to identical bytecode. *Its OCaml toolchain shuttles between Wax, WAT and binary, promising a faster, less error‑prone workflow for low‑level developers.
Jérôme Vouillon, principal software engineer at Tarides, unveiled Wax on 26 November 2026 as a direct response to the unwieldy WebAssembly codebase behind wasm_of_ocaml. The runtime consists of nearly 27,000 lines of hand‑crafted WebAssembly, spread across about fifty .wat files, each written in low‑level S‑expressions. That approach makes maintenance a slog and invites subtle bugs. Wax offers a Rust‑like surface that compiles to the exact same instructions, promising a faster, more reliable workflow for anyone who writes WebAssembly by hand. Its OCaml‑based toolchain bridges Wax, the human‑readable WAT format, and the binary, enabling round‑trip conversion without losing comments or layout.
The wasm_of_ocaml runtime ships roughly 27,000 lines of hand‑written WebAssembly spread across about fifty .wat files. Those files are written in S‑expressions where every variable read becomes a local.get and every loop a loop with a branch. The standard text format (WAT) was designed for disassembly, not for authoring. Developers spend hours maintaining verbose, error‑prone code. Wax replaces that with a Rust‑like syntax, letting programmers write the same instructions with familiar constructs such as #[export = "add"] and ordinary arithmetic. The result is code that is easier to read, write, and audit while still producing the exact same binary.
Wax’s compiler is written in OCaml and can convert Wax to WAT, WAT to Wax, and both to binary. A simple add function written in Wax compiles to a seven‑byte module identical to the hand‑written version. Each Wax construct maps directly onto a WebAssembly instruction: a while loop becomes a loop with a br back to its start, "+=" expands to i32.add followed by a local.set, and struct field access translates to a struct.get after a local.get. The toolchain also decompiles binaries back to Wax, preserving comments and formatting.
Although Wax grew out of the wasm_of_ocaml project, its design targets any developer who writes WebAssembly by hand. The recent WebAssembly GC proposal added structs, arrays, nullable references, subtyping and downcasts, making the text format even wordier. Wax mirrors these features with concise syntax: "l.value" replaces "(struct.get $list $value (local.get $l))" while preserving semantics. By handling both reference‑typed values and primitive types, Wax lets programmers represent OCaml‑style data structures directly in WebAssembly without resorting to raw linear memory tricks.
Wax ships a command‑line suite covering the full development cycle. "wax input.wax -o output.wasm" compiles to binary. "wax input.wax -f wat" emits the text format. "wax program.wasm" decompiles a binary back to Wax. "wax input.wat" converts WAT to Wax, while "wax format -i input.wax" rewrites files in place. "wax check input.wax" runs a type‑check only. The formatter retains comments and enforces a consistent layout, reducing manual cleanup. These utilities let developers move fluidly between source, inspection and deployment.
The runtime contains nearly 27,000 lines of WebAssembly written by hand.
Wax uses a Rust‑like syntax with a #[export = "function_name"] attribute before the fn declaration.
Yes, the toolchain can decompile a binary to Wax using the command "wax program.wasm".
By collapsing a 27,000‑line hand‑written runtime into a concise, Rust‑styled language, Wax could reshape how low‑level web code is authored and maintained. Its bidirectional conversion and full‑stack toolchain lower the barrier for developers to experiment with WebAssembly's emerging features, from GC‑enabled structs to reference types. If adoption spreads beyond the Tarides team, Wax may become the de‑facto lingua franca for hand‑crafted WebAssembly, accelerating innovation in browsers, edge runtimes and beyond.
Sources: [Hacker News – Wax: A User-Friendly Syntax for WebAssembly (https://tarides.com/blog/2026-11-26-wax/)]