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.
ocamlfind ocamlc -package js_of_ocaml -package js_of_ocaml.syntax \
-syntax camlp4o -linkpkg -o input_file.byte input_file.ml
js_of_ocaml [ options ] input_file.byte
OPTIONSThe following command-line options are recognized by js_of_ocaml(1).
- -debug name
- debug module name
- -disable name
- disable optimization name
- pretty print the output
- output debug info
- disable inlining
- do not include the standard runtime
- compile a toplevel
- -I dir
- Add dir to the list of include directories
- -o file
- set output file name to file
- Display the list of options
Display the list of options
FEATURES, LIMITATIONSThe 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;