ERCIM News No.36 - January 1999
Objective Caml - a General Purpose High-level Programming Language
by Xavier Leroy, Didier Rémy and Pierre Weis
Objective Caml is a general purpose programming language that combines functional, imperative, and object-oriented programming. The language is statically typed; its type system ensures the correct evaluation of programs. Types are automatically inferred. The language offers powerful constructions such as user-definable data-types, the ability to define functions by pattern-matching, and an exception mechanism. Programming in the large is facilitated by a full-fledge class-based object-oriented layer and an expressive module system.Objective Caml belongs to the ML family of programming languages and has been implemented at INRIA Rocquencourt within the Cristal research team. Since MLs inception in the late seventies, there has been a continuous line of research at INRIA devoted to implementations and improvements of ML. Objective Caml owes a lot to the original core ML language and to our first Caml implementation (1985-1990). A new byte-coded implementation called Caml Light was developed in the early nineties. The language Caml Light is still in use, especially for education. The language was renamed Objective Caml after the incorporation of a sophisticated module system and an object-oriented layer.
As all dialects of ML, Objective Caml possesses:
- first-class functions: functions can be passed to other functions, received as arguments, or returned as results
- a powerful type system with parametric polymorphism and type inference: functions may have polymorphic types; it is possible to define a type of collections parameterized by the type of the elements, and functions operating over such collections; for instance, the sorting procedure for arrays is defined for any array, regardless of the type of its elements
- user-definable data-types and pattern matching: the user can define new recursive data-types as a combination of record and variant types; more importantly, functions over such structures can be defined by pattern matching: a generalized case statement that allows the combination of multiple tests and multiple definitions of parts of the argument in a very compact way
- exceptions for error reporting and non-local control structures
- automatic memory management.
In addition, Objective Caml features:
- a sophisticated module system: program phrases can be grouped into structures, which can be named and nested; signatures are type specifications for structures; they can be used to hide some of the structure components or abstract over some type components. Functors, that is, functions from structures to structures, support parameterized modules
- an expressive class-based object-oriented layer that includes traditional imperative operations on objects and classes, multiple inheritance, binary methods, and functional updates.
The Objective Caml implementation comes with general purpose libraries (arbitrary precision arithmetics, multi-threading, a toolkit for graphical user interfaces, etc.) and a Unix-style programming environment including a replay debugger and a time profiler. Objective Caml programs can easily be interfaced with other languages, in particular with other C programs or libraries. The implementation is targeted towards separate compilation of stand-alone applications, although interactive use via a read-eval-print loop is also supported. Both compilation to byte-code (for portability) and to native assembly code (for performance) are supported. The native code compiler generates very efficient code, complemented by a fast, unobtrusive incremental garbage collector. The implementation runs on most Unix platforms (Linux, Digital Unix, Solaris, IRIX), under Windows 95 and NT, and on the Macintosh.
Objective Caml has been used in numerous applications involving symbolic computation (automatic theorem proving, compilation and interpretation, program analyses), and for the rapid development of applications in various areas: tools for the Web (browsers, intelligent proxies), network protocols (the Ensemble distributed communication system at Cornell, the SwitchWare active networking project at University of Pennsylvania), distributed computation, etc. The interactive system is well suited to scripting; the byte-code compiler and its dynamic linking capabilities make it possible to send or receive compiled programs from remote sites.
The Caml language is widely used for teaching in France at both undergraduate and graduate levels. It is also used in many academic projects in Europe, Japan, North and South America. Several large French corporations develop significant industrial projects in Objective Caml, including France Télécom, Dassault, and CEA (Commissariat à lÉnergie Atomique).
INRIA is setting up a Caml consortium, inspired by the World Wide Web consortium. It will offer industrial and academic partners to participate in the development, the maintenance, and the definition of new features of the language.
The Objective Caml implementation as well as extensive documentation on Caml are freely available on the Web, http://caml.inria.fr/
Please contact:
Xavier Leroy - INRIA
Tel: +33 1 3963 5561
E-mail: Xavier.Leroy@inria.fr