Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>There are lots of differences, some technical, some sociopolitical. I've tried to put more important differences first.</p> <ul> <li><p>SML is a language with a definition and a standard. It is stable (and in fact has been frozen so it cannot evolve). Objective Caml is an implementation controlled by a small group at INRIA. It continues to evolve. (IMO the evolution is managed well.)</p></li> <li><p>SML has many implementations; Caml has just one.</p></li> <li><p>Objective Caml has a number of additional features, among which the most prominent are probably objects and polymorphic variants.</p></li> <li><p>The two languages have dramatically different models of record types. Briefly, in Caml, names of record fields must be unique, where in SML, two different record types in the same scope may have field names in common. This quirk can make porting from SML to Caml a bit tricky.</p></li> <li><p>There are quite a few syntactic differences.</p></li> <li><p>The libraries and standard functions are dramatically different. The Caml library is very imperative, whereas the SML Standard Basis Library is more functional. For example, function composition is a top-level primitive in SML; it's not part of the Caml library. The Caml string library doesn't provide a fold function (at least not as of version 3.08). Implementations of many of the Caml <code>List</code> functions are unsafe for very long lists; they blow the stack.</p></li> <li><p>The type systems are subtly different: In Caml, a type annotation on an expression <code>e : ty</code> is accepted if the type <code>ty</code> <em>unifies</em> with the type of <code>e</code>. In SML, <code>e : ty</code> is accepted only if the type <code>ty</code> is an <em>instance</em> of the type of <code>e</code>. This distinction renders the annotation in Caml much less useful in practice, because it is impossible to use a type annotation to insist that an expression is polymorphic.</p></li> <li><p>Caml has a much more sane and sensible relationship between interfaces (called <em>module types</em> or <em>signatures</em>) and (concrete) implementations (called <em>modules</em> or <em>structures</em>) than SML. In SML pretty much anything goes and you have to rely on the programmer to establish good conventions. In Caml, good conventions are established and enforced by the compiler.</p></li> <li><p>In SML, arithmetic operators are overloaded to apply to both floating-point and integer data. In Caml, operators are not overloaded; floating-point operators are notated with an extra dot.</p></li> <li><p>In SML, the programmer can control the precedence and associtivity of infix operators. In Caml, these are determined by the first character of the operator's name. This restriction limits the benefits of being able to define your own infix notation.</p></li> </ul> <p>For a more detailed analysis complete with editorial comment, you could also look at <a href="http://adam.chlipala.net/mlcomp/" rel="noreferrer">Adam Chlipala's comparison page</a>.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload