CLU (programming language)

From Wikipedia, the free encyclopedia
  (Redirected from CLU programming language)
Jump to: navigation, search
CLU
Paradigm(s) multi-paradigm: object-oriented, procedural
Designed by Barbara Liskov and her students at MIT
Developer Barbara Liskov and her students at MIT
Appeared in 1974
Typing discipline strong
Major implementations Portable CLU, Native CLU, clu2c
Influenced by ALGOL 60, Lisp, Simula
Influenced Ada, Argus, Lua, Ruby, Sather, Swift[1]

CLU is a programming language created at MIT by Barbara Liskov and her students between 1974 and 1975. It was notable for its use of constructors for abstract data types that included the code that operated on them, a key step in the direction of object-oriented programming (OOP). However many of the other features of OOP are (intentionally) missing, notably inheritance.

Clusters[edit]

The syntax of CLU was based on ALGOL, 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).[2] 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 numbers:

    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, booleans, characters and strings.[2]

Other features[edit]

Another key feature of the CLU type system are iterators, which return objects from a collection one after the other.[2] Iterators were "black boxes" that offered an identical API 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 Iterator).

CLU also includes exception handling, based on various attempts in other languages; exceptions are raised using signal and handled with except.

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. 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.

CLU supported type parameterized user-defined data abstractions.

Influence on other programming languages[edit]

  • Python and Ruby borrowed several concepts from CLU (such as call by sharing, the yield statement, and multiple assignment[citation needed])
  • CLU and Ada were major inspirations for C++ templates.
  • CLU's exception handling mechanisms also influenced newer languages like Java and C++.
  • C++, C#, Python, and Sather include iterators, which first appeared in CLU.
  • Lua took multiple assignment and multiple returns from function calls from CLU.[3]

References[edit]

  1. ^ Lattner, Chris (2014-06-03). "Chris Lattner's Homepage". Chris Lattner. Retrieved 2014-06-03. "The Swift language is the product of tireless effort from a team of language experts, documentation gurus, compiler optimization ninjas, and an incredibly important internal dogfooding group who provided feedback to help refine and battle-test ideas. Of course, it also greatly benefited from the experiences hard-won by many other languages in the field, drawing ideas from Objective-C, Rust, Haskell, Ruby, Python, C#, CLU, and far too many others to list." 
  2. ^ a b c Liskov, B.; Snyder, A.; Atkinson, R.; Schaffert, C. (August 1977). "Abstraction mechanisms in CLU". Comm. ACM 20 (8): 564–576. doi:10.1145/359763.359789. Retrieved 24 May 2013.  edit
  3. ^ Ierusalimschy, R.; De Figueiredo, L. H.; Celes, W. (2007). "The evolution of Lua". Proceedings of the third ACM SIGPLAN conference on History of programming languages - HOPL III. pp. 2–1–2–26. doi:10.1145/1238844.1238846. ISBN 978-1-59593-766-7.  edit

External links[edit]