SML vs Ocaml for ECMA script spec.

Daniel C. Wang danwang74 at gmail.com
Sat Oct 21 10:18:57 PDT 2006


Also some tidbits from..
  http://www.ffconsultancy.com/free/ray_tracer/languages.html
who did an independent comparison of a ray-trace benchmark. I've snipped 
the bits I think are relevant to the discussion. This is the most 
relevant one:

<snip>
> Unlike SML, the OCaml language is not standardised and continues to 
> evolve. The evolution of OCaml has allowed it to adopt many new 
> programming constructs not found in SML, including polymorphic 
> variants and objects. However, the evolution of the OCaml language 
> sometimes renders old code uncompilable or, worse, different in terms 
> of performance or even correctness.

>
>   Ray tracer language comparison
>
> /*Update: *Lisp much faster! Non-whitespace character counts!/
>
> We have ported four progressively optimised versions of our cut-down 
> ray tracer 
> <http://www.ffconsultancy.com/free/ray_tracer/comparison.html> to C++ 
> <http://gcc.gnu.org/>, Java <http://www.java.com>, OCaml 
> <http://www.ocaml.org> and SML <http://www.standardml.org>. Joe 
> Marshall, Nathan Baum, Juho Snellman, Jeffrey Siskind and others have 
> kindly ported the programs to Common Lisp and Scheme. Thanks also to 
> Oleg Trott for pointing out an important error in our code.
>
<snip>
>
> The OCaml and SML implementations of the ray tracer are by far the 
> most succinct. The shortest OCaml implementation of the ray tracer 
> fits in only 55 lines. The longer OCaml and SML implementations are 
> significantly shorter and faster than the shortest implementations in 
> all of the other languages.
>
<snip>
> In addition to examining the fastest implementations, it is 
> interesting to look at the performance of simple implementations.
<snip>
>
> In 32-bit, Stalin-compiled Scheme is fastest, followed closely by the 
> more concise MLton-compiled SML program. OCaml, SML/NJ-compiled SML 
> and g++-compiled C++ all give similar performance. The Lisp is not 
> only 30% more verbose than the OCaml but is also 4.9x slower.
>
> Given their performance, it is remarkable that the Stalin and MLton 
> implementations are devoid of low-level optimisations and the C++ and 
> OCaml implementations only had minor design decisions made based upon 
> performance (the use of pass-by-reference in C++ and the 
> representation of vectors as records rather than tuples in OCaml).
>
> Not uncoincidentally, two of the best optimising compilers, Stalin and 
> MLton, are both whole-program optimising compilers, meaning they can 
> only compile whole (self-contained) programs. The C++ and OCaml 
> compilers allow partial recompilation, compile this whole program much 
> more quickly and still achieve very competitive performance.
>
<snip>
> Note that OCaml and SML/NJ compile faster than all of the other 
> languages and Stalin compiles the Scheme implementation three orders 
> of magnitude slower than SML/NJ, taking over 10 minutes to compile 
> this tiny program.
<snip>
> Unlike SML, the OCaml language is not standardised and continues to 
> evolve. The evolution of OCaml has allowed it to adopt many new 
> programming constructs not found in SML, including polymorphic 
> variants and objects. However, the evolution of the OCaml language 
> sometimes renders old code uncompilable or, worse, different in terms 
> of performance or even correctness.






More information about the Es4-discuss mailing list