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