CAL is the name of a programming language originally developed by Business Objects and now released as "Open Quark", with sources, under a BSD-style license. It is a lazy functional programming language similar to the Haskell programming language. An implementation is available from the Business Objects Labs site. CAL forms part of the Quark Framework which includes a visual programming tool, Gem Cutter.
One of the main objectives of the Quark Framework is to allow logic expressed in a declarative, lazy functional style to be easily and efficiently integrated into Java applications. CAL source is typically compiled directly to byte codes (though an interpreter is also available), and can be called from regular OO code. In turn CAL code can call any Java code. Evaluation of CAL programs, and exploration of results can be completely controlled by procedural code, allowing data transformation logic (for which CAL is ideally suited) to be flexibly integrated into Java applications. A Java program can also easily build new functions on-the-fly, to describe transient data flows, or to create persisted logic. This form of 'functional metaprogramming' is common in real-world deployments of the Quark Framework.
The CAL language borrows much from Haskell syntax, but also eschews some Haskell features. As such, CAL is a strongly typed, lazily evaluated functional language, supporting algebraic functions and data types with parametric polymorphism and type inferencing. CAL has special syntax for strings, tuples, characters, numbers, lists and records. Single parameter type classes are supported, with superclasses, derived instances, deriving clauses for common classes, default class methods and higher-kinded type variables. While doubtless a subjective measure, CAL's developers have tried to keep the language simple. In particular, only the expression style is supported (Haskell's equation based style with argument pattern matching is not supported), and CAL does not make use of layout (semicolons are required to terminate definitions). CAL also makes certain syntactic choices to align it more strongly with Java. For instance, Java's syntax for comments is used, and CAL's inline documentation comments are close to JavaDoc.
One of the main differences between Haskell and CAL is in the area of interfacing with the 'real world'. Whereas Haskell goes to great lengths to validate the purity of functions, CAL relies on the programmer to hide 'imported impurity', exposing pure functions from a module where impure imports are made. CAL has a range of mechanisms for controlling evaluation order and laziness. These are often essential tools in the creation of effective solutions with native functions, but are also important in the aforementioned interface with the stateful world. The choice to de-emphasise formal tracking of purity, in favour of mechanisms to allow the programmer to express the right logic, has proven to provide a good balance of flexibility and 'directness' when interfacing with external operations.
One of the main design goals for CAL was to make the language as comfortable as possible for mainstream developers to pick up and use effectively. This is reflected in choices for syntax, but also in conventions and patterns used within the standard libraries. For example, libraries use longer, descriptive names and are commented to explain the implementations and best practices for use.
To see some CAL language source code click here. This tutorial CAL module is designed as a top-to-bottom 'feature parade' to showcase basic syntax with examples of some built-in and user defined data structures.
Here are a few examples, derived from the tutorial module linked to in the preceding paragraph:
Read more about this topic: Quark Framework