Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Caml vs. Caml Light
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 1992-12-29 (14:58)
From: Xavier Leroy <xleroy@p...>
Subject: Caml vs. Caml Light
In reply to Paul Steckler's questions:

> What do I gain/lose by using Caml Light vs. CAML?

Things that work better in Caml:

* Arbitrary precision rational arithmetic (state-of-the-art
  implementation, very efficient).
* Overloading with compile-time resolution. Nice for e.g. programs
  that use mixed arithmetic a lot.
* Ability to embed ``object languages'', i.e. to call user-defined
  parsers from within the Caml parser.
* Powerful macros (at the level of the abstract syntax tree).
* Tools to write pretty-printers.
* Dynamic objects, for meta-level programming (eval) and type-safe
  structured I/O.
* Much more library functions (I would say "far too much", but that's
  a question of personal taste).

Things that work better in Caml Light:

* Much smaller, slightly faster, much more responsive (see below).
* High portability. Caml Light programs run unchanged on many
  platforms. The Caml Light system is easy to port to new platforms.
* Separate compilation is well supported.
* The module system is simple but highly practical.
* Streams and stream matching, providing a very simple way to write
* Better documentation.

> Are the input languages identical?

Not quite, but you can program for quite a while before noticing the
differences (unless you use the most advanced features of Caml, of
course). Actually, you'll notice much earlier the differences between
the Caml library and the Caml Light library. Overall, porting from
Caml to Caml Light is relatively easy.

> Is the performance comparable?

Caml produces native machine code, while Caml Light produces bytecode
for an abstract machine, which is interpreted later, hence Caml Light
should be much slower than Caml. But Caml Light has a more efficient
execution model, and above all a much better garbage collector: Caml
routinely spends more than half the time in garbage collection; with
Caml Light, this goes down to 10% or less. Overall, Caml Light is
slightly faster. This depends a lot on your application (Caml is
faster than Caml Light on raw integer arithmetic, but slower on
function calls) and on your machine (Caml works better on CISCs, Caml
Light really shines on RISCs).

- Xavier Leroy