Claire (programming language)
Claire | |
---|---|
Paradigm | multi-paradigm: functional, object-oriented, rule processing |
Designed by | Yves Caseau |
First appeared | 1994 |
Stable release | 3.3.46
/ February 17, 2009 |
Typing discipline | strong, both static and dynamic |
OS | Cross-platform |
License | Open-source: binary and source code are freely redistributable; the original copyright notice must be retained |
Filename extensions | .cl |
Website | www |
Major implementations | |
Free Claire (reference implementation), XL Claire | |
Influenced by | |
Smalltalk, SETL, OPS5, Lisp, ML, C, LORE, LAURE |
Claire is a high-level functional and object-oriented programming language with rule processing capabilities. It is intended to allow the programmer to express complex algorithms in a particularly compact and readable fashion, while imposing no performance overhead relative to C++. Its main designer is Yves Caseau.
Claire provides:
- truly polymorphic and parametric functional programming
- A simple object system with parametric classes and methods and single inheritance
- production rules triggered by events
- versioned snapshots of the whole system or any part of it, supporting rollback and easy exploration of search spaces
- explicit relations between entities; for instance, two entities might be declared inverses of one another
- first-class sets with convenient syntax for set-based programming
- an expressive set-based type system allowing both dynamic and static typing
The main implementation of Claire was fully open-sourced with the release of version 3.3.46 in February 2009. Commercial support is available for another implementation, XL Claire.
Overview
Claire is a general-purpose language, most suitable for sophisticated applications that involve complex data modeling, rule processing and problem solving.
It may be used for complete projects, but also integrates smoothly with C++ or Java: Claire programs may incorporate C++ or Java code, and Claire code may be translated into C++ or Java for use in C++ or Java projects. C++ is still the target language of choice, but Java is increasing in popularity.
The key set of features that distinguishes Claire from other programming languages has been dictated by experience gained in solving complex optimization problems.
Two features that distinguish Claire both from other functional and object-oriented languages, such as OCaml, Scala, or F#, are:
- Versioning: Claire supports versioning of a user-selected view of the entire system. The view can be made as large (for expressiveness) or as small (for efficiency) as is necessary. Versions are created linearly and can be viewed as a stack of snapshots of the system. Claire supports very efficient creation/roll-back of versions, which constitutes the basis for powerful backtracking, a key feature for problem solving. Unlike most logic programming languages, this type of backtracking covers any user-defined structure, not simply a set of logic variables.
- Production rules: Claire supports rules that bind a Claire expression (the conclusion) to the combination of an event and a logical condition. Whenever this event occurs, if the condition is verified, then the conclusion is evaluated. The emphasis on events is a natural evolution from rule-based inference engines and is well suited to the description of reactive algorithms such as constraint propagation.
Genetically, Claire is influenced by LORE and LAURE, languages developed in the 1980s for knowledge representation, optimization problems and real-time applications. Claire, however, was designed to be easier to learn and is much smaller, omitting features of LAURE such as constraints and deductive rules; it is also closer to C in spirit and syntax.
Example
A function to compute the nth fibonacci number:
fib(n:integer) : integer -> (if (n < 2) 1 else fib(n - 1) + fib(n - 2))
External links
- The latest version of Claire and its documentation are available from the "claireprogramminglanguage" Yahoo! group, which requires free registration.
- Commercial XL Claire site, a commercially supported reimplementation of the language for scripting and the web.
- Free Claire site, as of April 2009 partly outdated.
- Introduction to the CLAIRE Programming Language Version 3.2 Yves Caseau, François Laburthe