Claire (programming language)
Claire | |
---|---|
Paradigm | multi-paradigm: functional, object-oriented (class-based), rule processing, reflective |
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 | Permissive free software license |
Filename extensions | .cl |
Website | www |
Major implementations | |
Claire (reference implementation), WebClaire | |
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. Its main designer is Yves Caseau.
Claire provides:
- a simple object system with parametric classes and methods
- polymorphic and parametric functional programming
- production rules triggered by events
- versioned snapshots of the state of the whole system or any part of it, supporting rollback and easy exploration of search spaces
- explicit relations between entities; for example, 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 second-order static and dynamic typing
Claire's canonical implementation, providing both an interpreter and a compiler, was fully open-sourced with the release of version 3.3.46 in February 2009. Another implementation, WebClaire, is commercially supported.
Overview
Claire is a general-purpose language, most suitable for sophisticated applications that involve complex data modeling, rule processing and problem solving.
Though Claire can be used for complete projects, it is designed to integrate 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.
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 not found in other mixed functional/object-oriented languages, such as OCaml, Scala and F#, are versioning and production rules.
Claire supports versioning of a user-selected view of the system, which can be made as large (for expressiveness) or small (for efficiency) as necessary. Versions are created linearly and can be viewed as a stack of snapshots of the system. Creation and roll-back of versions permit backtracking, as found in logic programming, though Claire's backtracking may cover any user-defined structure rather than only a set of logic variables.
In Claire, a production rule is composed of an event, a condition and a response to be evaluated if the condition is satisfied. An event may be any change in an object's slot or the instantiation of a class, and a response may itself set off further events. Such production rules are especially useful in describing reactive algorithms, such as those for constraint propagation.
Claire was designed on the basis of experience with LAURE, an expressive but complex language of the 1980s that combined many paradigms. Claire was intended to be easier to learn than its predecessor, 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.
- WebClaire, a commercially supported implementation with extensions for web application programming.
- Documentation for Claire and WebClaire
- Introduction to the CLAIRE Programming Language Version 3.2 by Yves Caseau and François Laburthe