Menu

1 / 2

Wax: A User-Friendly Syntax for WebAssembly

#hackernews#technology#tarides#local#type
Long article (3071 words) — no AI summary yet.
Reading 0:00
15s threshold

The runtime of wasm_of_ocaml , the OCaml-to-WebAssembly compiler developed alongside js_of_ocaml, is nearly 27,000 lines of WebAssembly written by hand. It is the library of primitives that compiled OCaml code calls into for strings, polymorphic comparison, hashing, marshalling and effect handlers. Our 2025 work on making wasm_of_ocaml faster is described in an earlier post .

I wrote Wax to offer another way to write that code: a Rust-like syntax for WebAssembly that compiles to exactly the same instructions. It comes with a toolchain, written in OCaml, that converts between Wax and WebAssembly's text and binary formats in every direction. Although it grew out of wasm_of_ocaml, Wax is meant for anyone who writes WebAssembly by hand.

One function, three forms

WebAssembly (Wasm) is a compact binary instruction format for a stack machine : instructions take their operands from a stack and push their results back onto it.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.