<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta name="robots" content="index,nofollow">



<title>OCaml - MLton Standard ML Compiler (SML Compiler)</title>
<link rel="stylesheet" type="text/css" charset="iso-8859-1" media="all" href="common.css">
<link rel="stylesheet" type="text/css" charset="iso-8859-1" media="screen" href="screen.css">
<link rel="stylesheet" type="text/css" charset="iso-8859-1" media="print" href="print.css">


<link rel="Start" href="Home">


</head>

<body lang="en" dir="ltr">

<table bgcolor = lightblue cellspacing = 0 style = "border: 0px;" width = 100%>
  <tr>
    <td style = "
		border: 0px;
		color: darkblue; 
		font-size: 150%;
		text-align: left;">
      <a class = mltona href="Home">MLton 20051202</a>
    <td style = "
		border: 0px;
		font-size: 150%;
		text-align: center;
		width: 50%;">
      OCaml
    <td style = "
		border: 0px;
		text-align: right;">
      <table cellspacing = 0 style = "border: 0px">
        <tr style = "vertical-align: middle;">
      </table>
  <tr style = "background-color: white;">
    <td colspan = 3
	style = "
		border: 0px;
		font-size:70%;
		text-align: right;">
      <a href = "Home">Home</a>
      &nbsp;<a href = "Index">Index</a>
      &nbsp;
</table>
<div id="content" lang="en" dir="ltr">
<a class="external" href="http://caml.inria.fr/"><img src="moin-www.png" alt="[WWW]" height="11" width="11">OCaml</a> is a variant of <a href="ML">ML</a> and is similar to <a href="StandardML">Standard ML</a>. <h2 id="head-bdb603a1546c889e07912df83fb168fdc6469ce8">OCaml and SML</h2>
<p>
Here's a comparison of some aspects of the OCaml and SML languages. 
</p>

        <ul>

        <li>
<p>
 Standard ML has a formal <a href="DefinitionOfStandardML">Definition</a>,   while OCaml is specified by its lone implementation and informal   documentation.  
</p>
</li>
        <li class="gap">
<p>
 Standard ML has a number of <a href="StandardMLImplementations">compilers</a>,   while OCaml has only one. 
</p>
</li>
        <li class="gap">
<p>
 OCaml has built-in support for object-oriented programming, while   Standard ML does not (however, see <a href="ObjectOrientedProgramming">ObjectOrientedProgramming</a>). 
</p>
</li>
        <li class="gap">
<p>
 Andreas Rossberg has a   <a class="external" href="http://www.ps.uni-sb.de/~rossberg/SMLvsOcaml.html"><img src="moin-www.png" alt="[WWW]" height="11" width="11">side-by-side comparison</a>   of the syntax of SML and OCaml. 
</p>
</li>

        </ul>


<h2 id="head-305cf7c02f3e0da3e842ba7d0bcefe80ed2dbfd1">OCaml and MLton</h2>
<p>
Here's a comparison of some aspects of OCaml and MLton. 
</p>

    <ul>

    <li>
<p>
 Performance 
</p>
</li>

        <ul>

        <li>
<p>
 Both OCaml and MLton have excellent performance.  
</p>
</li>
        <li class="gap">
<p>
 MLton performs extensive <a href="WholeProgramOptimization">WholeProgramOptimization</a>, which can   provide substantial improvements in large, modular programs. 
</p>
</li>
        <li class="gap">
<p>
 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. 
</p>
</li>
        <li class="gap">
<p>
 MLton uses native types, like 64-bit floats, without any penalty   due to boxing.  OCaml, in some situations, boxes 64-bit floats. 
</p>
</li>
        <li class="gap">
<p>
 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. 
</p>
</li>
        <li class="gap">
<p>
 MLton represents records compactly by reordering and packing the   fields. 
</p>
</li>
        <li class="gap">
<p>
 In MLton, polymorphic and monomorphic code have the same   performance.  In OCaml, polymorphism can introduce a performance   penalty. 
</p>
</li>
        <li class="gap">
<p>
 In MLton, module boundaries have no impact on performance.  In   OCaml, moving code between modules can cause a performance penalty. 
</p>
</li>

        </ul>


    <li class="gap">
<p>
 MLton's <a href="ForeignFunctionInterface">ForeignFunctionInterface</a> is simpler than OCaml's. 
</p>
</li>
    <li class="gap">
<p>
 Tools 
</p>
</li>

        <ul>

        <li>
<p>
 OCaml has a debugger, while MLton does not. 
</p>
</li>
        <li class="gap">
<p>
 OCaml supports separate compilation, while MLton does not. 
</p>
</li>
        <li class="gap">
<p>
 OCaml compiles faster than MLton. 
</p>
</li>
        <li class="gap">
<p>
 MLton supports profiling of both time and allocation. 
</p>
</li>

        </ul>


    <li class="gap">
<p>
 Libraries 
</p>
</li>

        <ul>

        <li>
<p>
 OCaml has more available libraries. 
</p>
</li>

        </ul>


    <li class="gap">
<p>
 Community 
</p>
</li>

        <ul>

        <li>
<p>
 OCaml has a larger community than MLton.   
</p>
</li>
        <li class="gap">
<p>
 MLton has a very responsive   <a class="external" href="http://www.mlton.org/mailman/listinfo/mlton"><img src="moin-www.png" alt="[WWW]" height="11" width="11">developer list</a>. 
</p>
</li>
</ul>

</ul>

</div>



<p>
<hr>
Last edited on 2005-12-02 04:23:05 by <span title="ppp-71-139-183-221.dsl.snfc21.pacbell.net"><a href="StephenWeeks">StephenWeeks</a></span>.
</body></html>
