The big picture
What is Objective Caml?
Objective Caml is an implementation of the Caml dialect of ML
extended with class-based objects and a powerful module system in the
style of SML's.
It continues the Caml Light effort in many ways (separate compilation,
low memory requirements, fast turnaround through bytecode
interpretation), but also significantly departs from Caml Light on
other points (objects, the module calculus, and a high-performance
native-code compiler).
Objective Caml continues an earlier implementation of Caml plus
modules, known as Caml Special Light. The only difference between
Objective Caml and Caml Special Light is the addition of objects.
Should I switch from Caml Light to Objective Caml?
Caml Light is still maintained, though no longer actively
developed. We make bug-fix releases from time to time and still
provide support for it. It provides a more stable programming
environment than Objective Caml, which is still evolving, though at a
slower pace than immediately after its introduction.
If you're perfectly happy with Caml Light, value reliability more
than performance, don't need the new module system, don't need the new
object stuff, then stay with Caml Light. If you need objects,
powerful modules, the native-code compiler, or just like being on the
cutting edge, go for Objective Caml.
Objective Caml still does not conform to Standard ML, does it?
Of course not. We are supposed to do research in programming language
design and implementation. Implementing a standard is not research.
The ultimate aim of this whole effort is to make a language even
better than Standard ML. For instance, Objective Caml is today the
only ML dialect that supports object-oriented programming.
How do Objective Caml modules compare with Standard ML's?
From the user's point of view, both look pretty much the same and
offer similar expressive power. The theoretical foundations are
completely different, though. The main advantage of the Objective Caml
system is that it blends gracefully with Modula-2 style separate
compilation, while Standard ML modules provide rather poor support for
separate compilation. (See the papers for more
details.)
Compared with Standard ML proper, O'Caml's modules have in addition
signatures and functors as structure components, and fully transparent
higher-order functors in the style of New Jersey ML, though again
relying on a completely different theoretical approach.
How hard is it to convert code from Objective Caml 2.0 to
Objective Caml 3.0?
Very easy. The only change required is in stream patterns (change the
?
operator to ??
). With this exception,
all new features of 3.0 (labels, optional arguments, polymorphic variants)
introduce no incompatibilities with 2.0.
How hard is it to convert code from Objective Caml 1.0 to
Objective Caml 2.0?
If your code doesn't use classes and objects, almost no changes are
required. There are a couple of extra reserved keywords, and minor type
changes in e.g. the Unix library.
Class definitions need to be reworked to conform to the new syntax.
A semi-automatic translator is available and automates most of
the translation work.
The O'Caml distribution contains a script (in tools/convert
)
that performs automatically the renaming of library functions and
warns for usages of now-reserved keywords.
How hard is it to convert code from Caml Special Light to
Objective Caml?
Conversion to Objective Caml is extremely easy, Objective Caml
being almost 100% upwards compatible with Caml Special Light. The only
difference is that Objective Caml has some additional reserved
keywords such as new
and class
, which forced
some library functions to be renamed.
The O'Caml distribution contains a script (in tools/convert
)
that performs automatically the renaming of library functions and
warns for usages of now-reserved keywords.
How hard is it to convert code from Caml Light to Objective Caml?
Here is a list of the main differences:
- Capitalization of identifiers matters. Value names must be
in lowercase, constructors and exceptions capitalized, record labels
in lowercase, type constructors in lowercase.
- Types and exceptions defined manifestly in a module interface
(
.mli
file) must also be defined identically in the
implementation (.ml
file).
- Various minor syntactic changes, e.g. use of
.
instead of __
to extract module components, suppression of
;;
in files, characters literals between single quotes
'...'
instead of backquotes `...`
, etc.
- The standard library has been restructured, a number of functions
have changed names.
An automatic translator from Caml Light to Caml Special Light and
Objective Caml, written by Bruno Barras, is available
here.
Caml -
Objective Caml -
Projet Cristal -
Homepages -
Contact the Caml maintainers
Author: Xavier Leroy --
Last modified: 2003/05/09