Skip to content

Latest commit

 

History

History
60 lines (44 loc) · 2.66 KB

wasm_overview.wiki

File metadata and controls

60 lines (44 loc) · 2.66 KB

Table of Contents

Wasm_of_ocaml

Overview

Wasm_of_ocaml is a compiler from OCaml bytecode programs to WebAssembly. It provides an alternative way to run pure OCaml programs in JavaScript environments like browsers and Node.js.

The compiler is provided by the wasm_of_ocaml-compiler package. The <<a_manual chapter="overview"></a_manual>> are compatible with this compiler.

== Dependencies

Wasm_of_ocaml depends on the Binaryen toolchain version 119 or later.

== Installation

The easiest way to install wasm_of_ocaml is to use opam.

Usage

  Your program must first be compiled using the OCaml bytecode
  compiler .  JavaScript bindings are provided by the
   package and the syntax extension by the
   package

  Then, run the  compiler to produce Wasm code:

This produces a Javascript loading script cube.js} and a directory

one can enable the CPS transformation from by passing the { flag. Without the flag will instead default to

 and emit code utilizing
 <a href="https://github.com/WebAssembly/js-promise-integration/blob/main/proposals/js-promise-integration/Overview.md" target="_blank">the JavaScript-Promise Integration extension</a>.

The CPS transformation is not the default since the generated code is slower, larger and less readable. On the other hand, the JSPI extension is not yet enabled by default in Web browsers, and performing effects is slower when using this extension.