js_of_ocaml(1) OCaml bytecode to Javascript compiler

DESCRIPTION

js_of_ocaml(1) is a compiler from OCaml bytecode programs to Javascript. It makes it possible to write OCaml programs that run on web browsers.

It comes with bindings for a large part of the browser APIs, and the generated programs have been measured to typically run faster the OCaml bytecode interpreter.

USAGE

Your program must be first compiled using the OCaml bytecode compiler ocamlc(1). Javascript bindings, as well as a corresponding syntax extension, are provided by the js_of_ocaml package.


 ocamlfind ocamlc -package js_of_ocaml -package js_of_ocaml.syntax \
     -syntax camlp4o -linkpkg -o input_file.byte input_file.ml

Then, run the js_of_ocaml(1) compiler to produce Javascript code.

js_of_ocaml [ options ] input_file.byte

OPTIONS

The following command-line options are recognized by js_of_ocaml(1).
-debug name
debug module name
-disable name
disable optimization name
-pretty
pretty print the output
-debuginfo
output debug info
-noinline
disable inlining
-noruntime
do not include the standard runtime
-toplevel
compile a toplevel
-I dir
Add dir to the list of include directories
-o file
set output file name to file
-help
Display the list of options
--help
Display the list of options

FEATURES, LIMITATIONS

The whole OCaml standard library should be supported, except for input/output channels, weak references, and most functions of the Sys module. Extra libraries such as Bigarray, Unix, Thread or Str are not supported.

Tail call is not optimized in general. However, self-recursive functions (when the tail calls are to the function itself) are compiled into a loop.

Recursive modules are not supported at the moment.

Data representation differs from the usual one, for performance reasons. Most notably, integers are 32 bit (instead of 31 or 63 bits) and floats are not boxed. As a consequence, marshalling, polymorphic comparison, and hashing functions can yield results different than usual:

  • marshalling of floats is not supported (unmarshalling works);
  • the polymorphic hash function will not give the same results on data structures containing floats;
  • these functions may be more prone to stack overflow, as the Javascript stack is small.

AUTHORS

The Ocsigen Team <[email protected]>
Wrote the js_of_ocaml software.
Nicolas Dandrimont <[email protected]>
Wrote this manpage for the Debian system.