MLton

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.

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.