CLU programming language
Encyclopedia
CLU is a programming language
Programming language
A programming language is an artificial language designed to communicate instructions to a machine, particularly a computer. Programming languages can be used to create programs that control the behavior of a machine and/or to express algorithms precisely....

 created at MIT
Massachusetts Institute of Technology
The Massachusetts Institute of Technology is a private research university located in Cambridge, Massachusetts. MIT has five schools and one college, containing a total of 32 academic departments, with a strong emphasis on scientific and technological education and research.Founded in 1861 in...

 by Barbara Liskov
Barbara Liskov
Barbara Liskov is a computer scientist. She is currently the Ford Professor of Engineering in the MIT School of Engineering's Electrical Engineering and Computer Science department and an Institute Professor at the Massachusetts Institute of Technology.-Life and career:She earned her BA in...

 and her students between 1974 and 1975. It was notable for its use of constructors for abstract data types
Abstract data type
In computing, an abstract data type is a mathematical model for a certain class of data structures that have similar behavior; or for certain data types of one or more programming languages that have similar semantics...

 that included the code that operated on them, a key step in the direction of object-oriented programming
Object-oriented programming
Object-oriented programming is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their interactions – to design applications and computer programs. Programming techniques may include features such as data abstraction,...

 (OOP). However many of the other features of OOP are (intentionally) missing, notably inheritance, and the language is also hindered by a sometimes frustrating if elegant syntax.

Clusters

The syntax
Syntax
In linguistics, syntax is the study of the principles and rules for constructing phrases and sentences in natural languages....

 of CLU was based on ALGOL
ALGOL
ALGOL is a family of imperative computer programming languages originally developed in the mid 1950s which greatly influenced many other languages and became the de facto way algorithms were described in textbooks and academic works for almost the next 30 years...

, then the starting point for most new language design. The key addition was the concept of a cluster, CLU's type extension system and the root of the language's name (CLUster). Clusters correspond generally to the concept of an "object" in an OO language, and have roughly the same syntax. For instance, here is the CLU syntax for a cluster that implements complex number
Complex number
A complex number is a number consisting of a real part and an imaginary part. Complex numbers extend the idea of the one-dimensional number line to the two-dimensional complex plane by using the number line for the real part and adding a vertical axis to plot the imaginary part...

s:


complex_number = cluster is add, subtract, multiply, ...
rep = record [ real_part: real, imag_part: real ]
add = proc ... end add;
subtract = proc ... end subtract;
multiply = proc ... end multiply;
...
end complex_number;

Cluster names are global, and no namespace mechanism was provided to group clusters or allow them to be created "locally" inside other clusters.

CLU does not perform implicit type conversions. In a cluster, the explicit type conversions 'up' and 'down' change between the abstract type and the representation. There is a universal type 'any', and a procedure force[] to check that an object is a certain type. Objects may be mutable or immutable, the latter being "base types" such as integers.

Other features

Another key feature of the CLU type system are iterators, which return objects from a collection one after the other. Iterators were "black boxes" that offered an identical API
Application programming interface
An application programming interface is a source code based specification intended to be used as an interface by software components to communicate with each other...

 no matter what data they were being used with. Thus the iterator for a collection of complex_numbers would be identical to that for an array of integers. Iterators are now a common feature of most modern languages. (See Generator
Generator (computer science)
In computer science, a generator is a special routine that can be used to control the iteration behaviour of a loop. A generator is very similar to a function that returns an array, in that a generator has parameters, can be called, and generates a sequence of values...

)


CLU also includes exception handling
Exception handling
Exception handling is a programming language construct or computer hardware mechanism designed to handle the occurrence of exceptions, special conditions that change the normal flow of program execution....

, based on various attempts in other languages; exceptions are raised using signal and handled with except. Oddly, given the focus on type design, CLU does not offer enumerated type
Enumerated type
In computer programming, an enumerated type is a data type consisting of a set of named values called elements, members or enumerators of the type. The enumerator names are usually identifiers that behave as constants in the language...

s, nor any obvious way to create them.

A final distinctive feature in CLU is multiple assignment, where more than one variable can appear on the left hand side of an assignment operator
Assignment (computer science)
In computer programming, an assignment statement sets or re-sets the value stored in the storage location denoted by a variable name. In most imperative computer programming languages, assignment statements are one of the basic statements...

. For instance, writing x,y = y,x would exchange values of x and y. In the same way, functions could return several values, like x,y,z = f(t).

All objects in a CLU program live in the heap, and memory management is automatic.

Influence on other programming languages

  • Python
    Python (programming language)
    Python is a general-purpose, high-level programming language whose design philosophy emphasizes code readability. Python claims to "[combine] remarkable power with very clear syntax", and its standard library is large and comprehensive...

     and Ruby
    Ruby (programming language)
    Ruby is a dynamic, reflective, general-purpose object-oriented programming language that combines syntax inspired by Perl with Smalltalk-like features. Ruby originated in Japan during the mid-1990s and was first developed and designed by Yukihiro "Matz" Matsumoto...

     borrowed several concepts from CLU (such as the yield statement and multiple assignment)
  • CLU and Ada
    Ada (programming language)
    Ada is a structured, statically typed, imperative, wide-spectrum, and object-oriented high-level computer programming language, extended from Pascal and other languages...

     were major inspirations for C++
    C++
    C++ is a statically typed, free-form, multi-paradigm, compiled, general-purpose programming language. It is regarded as an intermediate-level language, as it comprises a combination of both high-level and low-level language features. It was developed by Bjarne Stroustrup starting in 1979 at Bell...

     templates.
  • CLU's exception handling mechanisms also influenced newer languages like Java
    Java (programming language)
    Java is a programming language originally developed by James Gosling at Sun Microsystems and released in 1995 as a core component of Sun Microsystems' Java platform. The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities...

     and C++.
  • All objects in a CLU program live in the heap, and memory management is automatic. These elements directly influenced Java.
  • Python, C#, and Sather
    Sather
    Sather is an object-oriented programming language. It originated circa 1990 at the International Computer Science Institute at the University of California, Berkeley, developed by an international team led by Steve Omohundro...

     include generator
    Generator (computer science)
    In computer science, a generator is a special routine that can be used to control the iteration behaviour of a loop. A generator is very similar to a function that returns an array, in that a generator has parameters, can be called, and generates a sequence of values...

    s (iterators in Sather and C#), which first appeared in CLU as iterators.
  • Lua took multiple assignment and multiple returns from function calls from CLU.

External links

  • CLU Home Page
  • A History of CLU (pdf)
  • clu2c: a program to compile CLU code to C
    C (programming language)
    C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system....

  • Dictionary of Programming Languages
  • CLU comparison at '99 bottles of beer' multi-language demo algorithm site
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK