Import Upstream version 20180207
[hcoop/debian/mlton.git] / doc / guide / src / OCaml.adoc
1 OCaml
2 =====
3
4 http://caml.inria.fr/[OCaml] is a variant of <:ML:> and is similar to
5 <:StandardML:Standard ML>.
6
7 == OCaml and SML ==
8
9 Here's a comparison of some aspects of the OCaml and SML languages.
10
11 * Standard ML has a formal <:DefinitionOfStandardML:Definition>, while
12 OCaml is specified by its lone implementation and informal
13 documentation.
14
15 * Standard ML has a number of <:StandardMLImplementations:compilers>,
16 while OCaml has only one.
17
18 * OCaml has built-in support for object-oriented programming, while
19 Standard ML does not (however, see <:ObjectOrientedProgramming:>).
20
21 * Andreas Rossberg has a
22 http://www.mpi-sws.org/%7Erossberg/sml-vs-ocaml.html[side-by-side
23 comparison] of the syntax of SML and OCaml.
24
25 * Adam Chlipala has a
26 http://adam.chlipala.net/mlcomp[point-by-point comparison] of OCaml
27 and SML.
28
29 == OCaml and MLton ==
30
31 Here's a comparison of some aspects of OCaml and MLton.
32
33 * Performance
34
35 ** Both OCaml and MLton have excellent performance.
36
37 ** MLton performs extensive <:WholeProgramOptimization:>, which can
38 provide substantial improvements in large, modular programs.
39
40 ** MLton uses native types, like 32-bit integers, without any penalty
41 due to tagging or boxing. OCaml uses 31-bit integers with a penalty
42 due to tagging, and 32-bit integers with a penalty due to boxing.
43
44 ** MLton uses native types, like 64-bit floats, without any penalty
45 due to boxing. OCaml, in some situations, boxes 64-bit floats.
46
47 ** MLton represents arrays of all types unboxed. In OCaml, only
48 arrays of 64-bit floats are unboxed, and then only when it is
49 syntactically apparent.
50
51 ** MLton represents records compactly by reordering and packing the
52 fields.
53
54 ** In MLton, polymorphic and monomorphic code have the same
55 performance. In OCaml, polymorphism can introduce a performance
56 penalty.
57
58 ** In MLton, module boundaries have no impact on performance. In
59 OCaml, moving code between modules can cause a performance penalty.
60
61 ** MLton's <:ForeignFunctionInterface:> is simpler than OCaml's.
62
63 * Tools
64
65 ** OCaml has a debugger, while MLton does not.
66
67 ** OCaml supports separate compilation, while MLton does not.
68
69 ** OCaml compiles faster than MLton.
70
71 ** MLton supports profiling of both time and allocation.
72
73 * Libraries
74
75 ** OCaml has more available libraries.
76
77 * Community
78
79 ** OCaml has a larger community than MLton.
80
81 ** MLton has a very responsive
82 http://www.mlton.org/mailman/listinfo/mlton[developer list].