An update from the ocaml-wasm organization

Summer and ICFP has passed since we announced the ocaml-wasm organization in July. Here we provide an update from the wasocaml and wasm_of_ocaml compiler projects since then.


WebAssembly (Wasm) is an attractive compilation target for OCaml, as it holds promises of better web-performance than compiling to JavaScript and furthermore opens up for running OCaml on new platforms. The ocaml-wasm organization is a joint effort between two Wasm-targeting compiler projects for OCaml:

  • wasocaml - an FLambda-based backend for OCaml’s native code compiler
  • wasm_of_ocaml - a fork of js_of_ocaml that consumes OCaml bytecode and emits Wasm instead of JavaScript

Both compilers depend on the proposed garbage collection (GC) extension to Wasm, which is available behind a flag in development versions of Chrome, Firefox, and Node.js. As a first news item, we are excited to share that the Wasm GC proposal has moved to stage 4. As a consequence Chrome is planning to enable the WasmGC extension in version 119, scheduled to release in November! :tada:



@vouillon has made solid progress on implementing run-time bindings, which means that
wasm_of_ocaml can now

Early benchmarks results are encouraging: Compiled programs typically run around 10-20% faster compared to the js_of_ocaml equivalent.

A more detailed status:


Please note that Wasocaml was also presented at IFL’23. (I could have tell you if you asked before doing the announce :wink: )

(Also it’s Flambda not FLambda)

Hi @zapashcanon, the announcement has been read and approved by one of your PhD advisors @chambart who is working with you closely on the wasocaml project. We would be happy to share a draft of the subsequent announcements with you so that you can incorporate your changes.

Hum yes sorry @zapashcanon I didn’t notice that… Oups

Is there any news on how wasocaml and wasm_of_ocaml compare to each other in performance?

I’m also curious how people think about the 10-20% improvement for wasm_of_ocaml over js_of_ocaml. I’m not sure whether to be disappointed in the former or impressed about the speed of the latter!



I don’t know of such a comparison, sorry.

I suspect wasocaml’s Flambda-based optimizations to be a clear win in some cases and wasm_of_ocaml’s whole-program mode to win in other cases.

Note: the 10-20% is a rough average covering a lot of variation of everything from no improvement to speed-ups of up to 50-66% in the best cases.
There has been no effort to optimize the JavaScript interface yet, so performance is likely to improve.

1 Like

I get a 30% performance improvement for both ocamlc and the CAMLBOY benchmark. I think @jmid was mostly commenting on the Bonsai benchmarks, where we observe a 40% to 50% performance improvement for some benchmarks but no improvement for others.