Wasocaml: a compiler from OCaml to WebAssembly
summary
Wasocaml compiles OCaml (from the Flambda stage) to WebAssembly GC and ships a working prototype runtime that uses Wasm features like structs and subtyping, funcref/externref and the exception proposal; closures are closure-converted and encoded as recursive Wasm types, arrays and small ints map to Wasm arrays/32-bit refs, and a simpler fallback treats everything as shifted ints in arrays. The prototype has no full standard library and no browser-ready build yet, runs microbenchmarks about 2x slower than native but gives predictable performance.
AI-written summary · about
chapters (17)
- 0:00WasOcaml introduction
- 1:07Compile OCaml to Wasm
- 2:56GC language challenges
- 4:43WMGC memory model
- 6:09OCaml compiler chain
- 8:17F Lambda representation
- 10:08Type representation and subtyping in WebAssembly
- 13:21OCaml modules handling
- 15:30Naive type encoding
- 16:15Encoding closures in WebAssembly
- 17:22Recursive types casting
- 19:08OCaml exceptions
- 20:14Compiler validation
- 21:38Current WasOcaml limits
- 23:46Performance benchmarks
- 25:55JS and web interaction
- 28:00Q&A exceptions








