Previous Contents Next

Description of the language

Objective CAML is a functional language:
it manipulates functions as values in the language. These can in turn be passed as arguments to other functions or returned as the result of a function call.

Objective CAML is statically typed:
verification of compatibility between the types of formal and actual parameters is carried out at program compilation time. From then on it is not necessary to perform such verification during the execution of the program, which increases its efficiency. Moreover, verification of typing permits the elimination of most errors introduced by typos or thoughtlessness and contributes to execution safety.

Objective CAML has parametric polymorphism:
a function which does not traverse the totality of the structure of one of its arguments accepts that the type of this argument is not fully determined. In this case this parameter is said to be polymorphic. This feature permits development of generic code usable for different data structures, such that the exact representation of this structure need not be known by the code in question. The typing algorithm is in a position to make this distinction.

Objective CAML has type inference:
the programmer need not give any type information within the program. The language alone is in charge of deducing from the code the most general type of the expressions and declarations therein. This inference is carried out jointly with verification, during program compilation.

Objective CAML is equipped with an exception mechanism:
it is possible to interrupt the normal execution of a program in one place and resume at another place thanks to this facility. This mechanism allows control of exceptional situations, but it can also be adopted as a programming style.

Objective CAML has imperative features:
I/O, physical modification of values and iterative control structures are possible without having recourse to functional programming features. Mixture of the two styles is acceptable, and offers great development flexibility as well as the possibility of defining new data structures.

Objective CAML executes (threads):
the principal tools for creation, synchronization, management of shared memory, and interthread communication are predefined.

Objective CAML communicates on the Internet:
the support functions needed to open communication channels between different machines are predefined and permit the development of client-server applications.

Numerous libraries are available for Objective CAML:
classic data structures, I/O, interfacing with system resources, lexical and syntactic analysis, computation with large numbers, persistent values, etc.

A programming environment is available for Objective CAML:
including interactive toplevel, execution trace, dependency calculation and profiling.

Objective CAML interfaces with the C language:
by calling C functions from an Objective CAML program and vice versa, thus permitting access to numerous C libraries.

Three execution modes are available for Objective CAML:
interactive by means of an interactive toplevel, compilation to bytecodes interpreted by a virtual machine, compilation to native machine code. The programmer can thus choose between flexibility of development, portability of object code between different architectures, or performance on a given architecture.

Structure of a program

Development of important applications requires the programmer or the development team to consider questions of organization and structure. In Objective CAML, two models are available with distinct advantages and features.
The parameterized module model:
data and procedures are gathered within a single entity with two facets: the code proper, and its interface. Communication between modules takes place via their interface. The description of a type may be hidden, not appearing in the module interface. These abstract data types facilitate modifications of the internal implementation of a module without affecting other modules which use it. Moreover, modules can be parameterized by other modules, thus increasing their reusability.

The object model:
descriptions of procedures and data are gathered into entities called classes; an object is an instance (value) of a class. Interobject communication is implemented through ``message passing'', the receiving object determines upon execution (late binding) the procedure corresponding to the message. In this way, object-oriented programming is ``data-driven''. The program structure comes from the relationships between classes; in particular inheritance lets one class be defined by extending another. This model allows concrete, abstract and parameterized classes. Furthermore, it introduces polymorphism of inclusion by defining the subtyping relationship between classes.

The choice between these two models allows great flexibility in the logical organization of an application and facilitates its maintenance and evolution. There is a duality between these two models. One cannot add data fields to a module type (no extensibility of data), but one can add new procedures (extensibility of procedures) acting on data. In the object model, one can add subclasses of a class (extensibility of data) for dealing with new cases, but one cannot add new procedures visible from the ancestor class (no extensibility of procedures). Nevertheless the combination of the two offers new possibilities for extending data and procedures.

Safety and efficiency of execution

Objective CAML bestows excellent execution safety on its programs without sacrificing their efficiency. Fundamentally, static typing is a guarantee of the absence of run-time type errors and makes useful static information available to the compiler without burdening performance with dynamic type tests. These benefits also extend to the object-oriented language features. Moreover, the built-in garbage collector adds to the safety of the language system. Objective CAML's is particularly efficient. The exception mechanism guarantees that the program will not find itself in an inconsistent state after a division by zero or an access outside the bounds of an array.

Previous Contents Next