English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
More cores
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2008-12-22 (16:57)
From: Jon Harrop <jon@f...>
Subject: Re: [Caml-list] More Caml
On Friday 19 December 2008 22:53:15 Jon Harrop wrote:
> On Friday 19 December 2008 22:36:40 Erik de Castro Lopo wrote:
> > Jon Harrop wrote:
> > > I have actually already started this using the excellent LLVM project
> > > and I just obtained the first promising results yesterday: a simple
> > > benchmark where my compiler runs OCaml code 3x faster than ocamlopt
> > > does.
> >
> > Is this going to be an open source project?
> Yes.

Just to update: I've spent a couple more days playing with this. I now have 
unit, bools, ints, floats, arrays, fast internal calling convention with tail 
calls, C-compatible external calling convention, arbitrary extern functions, 
C printf, multiple function arguments and multiple function return values 
(passed on the stack!). I have written a few tiny benchmarks and the results 
compared to OCaml on x86 are promising:

  Float Fibonacci: 2.9x faster than OCaml.
  Sieve of Eratosthenes: 1.8x faster than OCaml.
  Mandelbrot: 2.9x faster than OCaml.

The compiler is only ~500LOC. The language still lacks closures, a garbage 
collector, algebraic datatypes, pattern matching, polymorphism, exceptions, 
run-time types and safety (!). However, it already has some killer features:

  . Declare and then call C functions directly.

  . No 16Mb limits.

  . Very fast JIT compilation (2x faster than ocamlopt).

  . Easy incremental native-code compilation for a REPL.

  . Efficient polymorphism.

LLVM even does a decent job of statically type checking the code, which helps 
a lot when debugging (once you get used to the error messages!).

I'll probably write a front end or REPL using camlp4 and then port my ray 
tracer benchmark to it. After that, I'll look at some more features:

  . Algebraic data types and a kind of switch over them as a poor man's 
pattern matching.

  . Run-time type information and generic printing.

  . Real polymorphism.

  . Garbage collection.

This begs the question: what is the simplest possible concurrent GC?

Merry Christmas,
Dr Jon Harrop, Flying Frog Consultancy Ltd.