Wasocaml: compiling OCaml to WebAssembly - Inria - Institut national de recherche en sciences et technologies du numérique Access content directly
Conference Papers Year : 2023

Wasocaml: compiling OCaml to WebAssembly


The limitations of JavaScript as the default language of the web led to the development of Wasm, a secure, efficient and modular language. However, compiling garbage-collected languages to Wasm presents challenges, including the need to compile or reimplement the runtime. Some Wasm extensions such as Wasm-GC are developed by the Wasm working groups to facilitate the compilation of garbage-collected languages. We present Wasocaml, an OCaml to Wasm-GC compiler. It is the first compiler for a realworld functional programming language targeting Wasm-GC. Wasocaml confirms the adequacy of the Wasm-GC proposal for a functional language and had an impact on the design of the proposal. Moreover, the compilation strategies developed within Wasocaml are applicable to other compilers and languages. Indeed, two compilers already used a design similar to our. Finally, we describe how we plan to handle the C/JavaScript FFIs and effects handlers, in order to allow developers to easily deploy programs mixing C, JavaScript and OCaml code to the web, while maintaining good performances. CCS CONCEPTS • Software and its engineering → Compilers.


Fichier principal
Vignette du fichier
main.pdf (202.54 Ko) Télécharger le fichier
Origin Files produced by the author(s)

Dates and versions

hal-04311345 , version 1 (28-11-2023)
hal-04311345 , version 2 (13-12-2023)



  • HAL Id : hal-04311345 , version 2


Léo Andrès, Pierre Chambart, Jean-Christophe Filliâtre. Wasocaml: compiling OCaml to WebAssembly. IFL 2023 - The 35th Symposium on Implementation and Application of Functional Languages, João Saraiva; João Fernandes, Aug 2023, Braga, Portugal. ⟨hal-04311345v2⟩
191 View
94 Download


Gmail Mastodon Facebook X LinkedIn More