Js_of_ocaml is composed of multiple packages:
- js_of_ocaml-compiler, the compiler.
- js_of_ocaml-ppx, the ppx syntax extension (recommended).
- js_of_ocaml-camlp4, the camlp4 syntax extension (deprecated).
- js_of_ocaml, the base library.
- js_of_ocaml-lwt, lwt support.
- js_of_ocaml-tyxml, tyxml support.
- Cmdliner, cppo (for the compiler)
- ppx_tools_versioned, ocaml-migrate-parsetree (for the js_of_ocaml base library)
See opam files at the root of the repository for version constraints.
- deriving(see https://github.com/ocsigen/deriving )
- ppx_deriving(see https://github.com/whitequark/ppx_deriving )
- tyxml(see https://github.com/ocsigen/tyxml )
- reactiveData(see https://github.com/ocsigen/reactiveData )
- yojson(see https://github.com/mjambon/yojson )
Install from opam
opam install js_of_ocaml js_of_ocaml-ppx js_of_ocaml-lwt
Build and install from source
make opam-installer js_of_ocaml-compiler opam-installer js_of_ocaml opam-installer js_of_ocaml-ppx opam-installer js_of_ocaml-lwt
ocamlfind ocamlc -package js_of_ocaml -package js_of_ocaml-ppx \ -linkpkg -o cubes.byte cubes.ml
Js_of_ocaml also provide an ocamlbuild plugin. See Ocamlbuild_js_of_ocaml.
See also Quickstart.
Most of the OCaml standard library is supported. However,
- Most of Sys module is not supported.
Extra libraries distributed with Ocaml (such as Thread or Str) are not supported in general. However,
- Bigarray: bigarray are supported using Typed Arrays
- Num: supported using `+nat.js` option
- Graphics: partially supported using canvas (see also js_of_ocaml-graphics)
- Unix: time related functions are supported
Tail call is not optimized in general. However, mutually recursive functions are optimized:
- self recursive functions (when the tail calls are the function itself) are compiled using a loop.
- trampolines are used otherwise. More about tail call optimization.
- marshalling of floats is not supported (unmarshalling works);
- the polymorphic hash function will not give the same results on datastructures containing floats;
- these functions may be more prone to stack overflow.