MLton MLTONWIKIVERSION

OCaml

Home Index

OCaml is a variant of ML and is similar to Standard ML.

## OCaml and SML

Here's a comparison of some aspects of the OCaml and SML languages.

- Standard ML has a formal Definition, while OCaml is specified by its lone implementation and informal documentation.

- Standard ML has a number of compilers, while OCaml has only one.

- OCaml has built-in support for object-oriented programming, while Standard ML does not (however, see ObjectOrientedProgramming).

- Andreas Rossberg has a side-by-side comparison of the syntax of SML and OCaml.

## OCaml and MLton

Here's a comparison of some aspects of OCaml and MLton.

- Performance

- Both OCaml and MLton have excellent performance.

- MLton performs extensive WholeProgramOptimization, which can provide substantial improvements in large, modular programs.

- MLton uses native types, like 32-bit integers, without any penalty due to tagging or boxing. OCaml uses 31-bit integers with a penalty due to tagging, and 32-bit integers with a penalty due to boxing.

- MLton uses native types, like 64-bit floats, without any penalty due to boxing. OCaml, in some situations, boxes 64-bit floats.

- MLton represents arrays of all types unboxed. In OCaml, only arrays of 64-bit floats are unboxed, and then only when it is syntactically apparent.

- MLton represents records compactly by reordering and packing the fields.

- In MLton, polymorphic and monomorphic code have the same performance. In OCaml, polymorphism can introduce a performance penalty.

- In MLton, module boundaries have no impact on performance. In OCaml, moving code between modules can cause a performance penalty.

- MLton's ForeignFunctionInterface is simpler than OCaml's.

- Tools

- OCaml has a debugger, while MLton does not.

- OCaml supports separate compilation, while MLton does not.

- OCaml compiles faster than MLton.

- MLton supports profiling of both time and allocation.

- Libraries

- OCaml has more available libraries.

- Community

- OCaml has a larger community than MLton.

- MLton has a very responsive developer list.

Last edited on 2005-12-02 04:23:05 by StephenWeeks.