CLU (programming language)

Last updated
CLU
Paradigm multi-paradigm: object-oriented, procedural
Designed by Barbara Liskov and her students
Developer Massachusetts Institute of Technology
First appeared1975;47 years ago (1975)
Stable release
Native CLU 1.5 (SPARC, VAX) / May 26, 1989;33 years ago (1989-05-26) [1]

Portable CLU / November 6, 2009;12 years ago (2009-11-06) [2]

Contents

Typing discipline strong
Website pmg.csail.mit.edu/CLU.html
Major implementations
PDP-10 CLU, [3] Native CLU, [1] Portable CLU, [2] clu2c [4]
Influenced by
ALGOL 60, Lisp, Simula, Alphard
Influenced
Ada, Argus, C++, [5] Lua, Python, [6] Ruby, Sather, Swift [7]

CLU is a programming language created at the Massachusetts Institute of Technology (MIT) by Barbara Liskov and her students starting in 1973. [8] While it did not find extensive use, it introduced many features that are used widely now, and is seen as a step in the development of object-oriented programming (OOP).

Key contributions include abstract data types, [9] call-by-sharing, iterators, multiple return values (a form of parallel assignment), type-safe parameterized types, and type-safe variant types. It is also notable for its use of classes with constructors and methods, but without inheritance.

Clusters

The syntax of CLU was based on ALGOL, then the starting point for most new language designs. The key addition was the concept of a cluster, CLU's type extension system and the root of the language's name (CLUster). [10] Clusters correspond generally to the concept of a "class" in an OO language. 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; 

A cluster is a module that encapsulates all of its components except for those explicitly named in the "is" clause. These correspond to the public components of a class in recent OO languages. A cluster also defines a type that can be named outside the cluster (in this case, "complex_number"), but its representation type (rep) is hidden from external clients.

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

In a cluster, the explicit type conversions up and down change between the abstract type and the representation; implicit conversions between these types are signified using the special type cvt. CLU does not otherwise perform implicit type conversions. 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. [10]

Other features

Another key feature of the CLU type system are iterators , which return objects from a collection serially, one after another. [10] Iterators offer an identical application programming interface (API) no matter what data they are being used with. Thus the iterator for a collection of complex_numbers can be used interchangeably with that for an array of integers. A distinctive feature of CLU iterators is that they are implemented as coroutines, with each value being provided to the caller via a yield statement. Iterators like those in CLU are now a common feature of many modern languages, such as C#, Ruby, and Python, though recently they are often referred to as generators.

CLU also includes exception handling, based on various attempts in other languages; exceptions are raised using signal and handled with except. Unlike most other languages with exception handling, exceptions are not implicitly resignaled up the calling chain. Also unlike most other languages that provide exception handling, exceptions in CLU are considered part of ordinary execution flow and are considered a "normal" and efficient type-safe way to break out of loops or to return from functions; this allows for direct assignment of return values "except when" other conditions apply. Exceptions that are neither caught nor resignaled explicitly are immediately converted into a special failure exception that typically terminates the program.

CLU is often credited as being the first language with type-safe variant types, called oneofs, before the language ML had them.

A final distinctive feature in CLU is parallel assignment (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). Parallel assignment (though not multiple return values) predates CLU, appearing in CPL (1963), named simultaneous assignment, [11] but CLU popularized it and is often credited as the direct influence leading to parallel assignment in later languages.

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

CLU supports type-parameterized user-defined data abstractions. It was the first language to offer type-safe bounded parameterized types, using where clauses to express constraints on actual type arguments. Unlike in languages with template-based generics, a use of such a data abstraction can be type-checked without access to the implementation of the abstraction.

Influence

CLU and Ada were major inspirations for C++ templates. [5]

CLU's exception handling mechanisms influenced later languages like C++ [5] and Java.[ citation needed ]

Sather, Python, and C# include iterators, which first appeared in CLU. [8]

Perl and Lua took multiple assignment and multiple returns from function calls from CLU. [12]

Python and Ruby borrowed call by sharing, the yield statement, [13] and multiple assignment. [14]

Related Research Articles

In computer science, an abstract data type (ADT) is a mathematical model for data types. An abstract data type is defined by its behavior (semantics) from the point of view of a user, of the data, specifically in terms of possible values, possible operations on data of this type, and the behavior of these operations. This mathematical model contrasts with data structures, which are concrete representations of data, and are the point of view of an implementer, not a user.

Eiffel is an object-oriented programming language designed by Bertrand Meyer and Eiffel Software. Meyer conceived the language in 1985 with the goal of increasing the reliability of commercial software development; the first version becoming available in 1986. In 2005, Eiffel became an ISO-standardized language.

Ruby (programming language) General-purpose programming language

Ruby is an interpreted, high-level, general-purpose programming language which supports multiple programming paradigms. It was designed with an emphasis on programming productivity and simplicity. In Ruby, everything is an object, including primitive data types. It was developed in the mid-1990s by Yukihiro "Matz" Matsumoto in Japan.

In computer science, syntactic sugar is syntax within a programming language that is designed to make things easier to read or to express. It makes the language "sweeter" for human use: things can be expressed more clearly, more concisely, or in an alternative style that some may prefer.

In computer science, control flow is the order in which individual statements, instructions or function calls of an imperative program are executed or evaluated. The emphasis on explicit control flow distinguishes an imperative programming language from a declarative programming language.

In computing and computer programming, exception handling is the process of responding to the occurrence of exceptions – anomalous or exceptional conditions requiring special processing – during the execution of a program. In general, an exception breaks the normal flow of execution and executes a pre-registered exception handler; the details of how this is done depend on whether it is a hardware or software exception and how the software exception is implemented. Exception handling, if provided, is facilitated by specialized programming language constructs, hardware mechanisms like interrupts, or operating system (OS) inter-process communication (IPC) facilities like signals. Some exceptions, especially hardware ones, may be handled so gracefully that execution can resume where it was interrupted.

In software engineering and computer science, abstraction is:

In knowledge representation, object-oriented programming and design, is-a is a subsumption relationship between abstractions, wherein one class A is a subclass of another class B . In other words, type A is a subtype of type B when A's specification implies B's specification. That is, any object that satisfies A's specification also satisfies B's specification, because B's specification is weaker.

Liskov substitution principle Object-oriented programming principle

The Liskov substitution principle (LSP) is a particular definition of a subtyping relation, called strong behavioral subtyping, that was initially introduced by Barbara Liskov in a 1988 conference keynote address titled Data abstraction and hierarchy. It is based on the concept of "substitutability" – a principle in object-oriented programming stating that an object and a sub-object must be interchangeable without breaking the program. It is a semantic rather than merely syntactic relation, because it intends to guarantee semantic interoperability of types in a hierarchy, object types in particular. Barbara Liskov and Jeannette Wing described the principle succinctly in a 1994 paper as follows:

Subtype Requirement: Let be a property provable about objects of type T. Then should be true for objects of type S where S is a subtype of T.

In computer programming, an assignment statement sets and/or re-sets the value stored in the storage location(s) denoted by a variable name; in other words, it copies a value into the variable. In most imperative programming languages, the assignment statement is a fundamental construct.

In computer science, a generator is a routine that can be used to control the iteration behaviour of a loop. All generators are also iterators. 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. However, instead of building an array containing all the values and returning them all at once, a generator yields the values one at a time, which requires less memory and allows the caller to get started processing the first few values immediately. In short, a generator looks like a function but behaves like an iterator.

Many programming language type systems support subtyping. For instance, if the type Cat is a subtype of Animal, then an expression of type Cat should be substitutable wherever an expression of type Animal is used.

SIGPLAN is the Association for Computing Machinery's Special Interest Group on programming languages.

Barbara Liskov American computer scientist

Barbara Liskov is an American computer scientist who has made pioneering contributions to programming languages and distributed computing. Her notable work includes the development of the Liskov substitution principle which describes the fundamental nature of data abstraction, and is used in type theory and in object-oriented programming. Her work was recognized with the 2008 Turing Award, the highest distinction in computer science.

In computer science, future, promise, delay, and deferred refer to constructs used for synchronizing program execution in some concurrent programming languages. They describe an object that acts as a proxy for a result that is initially unknown, usually because the computation of its value is not yet complete.

In a programming language, an evaluation strategy is a set of rules for evaluating expressions. The term is often used to refer to the more specific notion of a parameter-passing strategy that defines the kind of value that is passed to the function for each parameter and whether to evaluate the parameters of a function call, and if so in what order. The notion of reduction strategy is distinct, although some authors conflate the two terms and the definition of each term is not widely agreed upon.

In object-oriented programming, behavioral subtyping is the principle that subclasses should satisfy the expectations of clients accessing subclass objects through references of superclass type, not just as regards syntactic safety but also as regards behavioral correctness. Specifically, properties that clients can prove using the specification of an object's presumed type should hold even though the object is actually a member of a subtype of that type.

In computer programming, one of the many ways that programming languages are colloquially classified is whether the language's type system makes it strongly typed or weakly typed. However, there is no precise technical definition of what the terms mean and different authors disagree about the implied meaning of the terms and the relative rankings of the "strength" of the type systems of mainstream programming languages.

Swift is a general-purpose, multi-paradigm, compiled programming language developed by Apple Inc. and the open-source community. First released in 2014, Swift was developed as a replacement for Apple's earlier programming language Objective-C, as Objective-C had been largely unchanged since the early 1980s and lacked modern language features. Swift works with Apple's Cocoa and Cocoa Touch frameworks, and a key aspect of Swift's design was the ability to interoperate with the huge body of existing Objective-C code developed for Apple products over the previous decades. It was built with the open source LLVM compiler framework and has been included in Xcode since version 6, released in 2014. On Apple platforms, it uses the Objective-C runtime library, which allows C, Objective-C, C++ and Swift code to run within one program.

References

  1. 1 2 Curtis, Dorothy (2009-11-06). "CLU home page". Programming Methodology Group, Computer Science and Artificial Intelligence Laboratory. Massachusetts Institute of Technology. Retrieved 2016-05-26.
  2. 1 2 Curtis, Dorothy (2009-11-06). "Index of /pub/pclu". Programming Methodology Group, Computer Science and Artificial Intelligence Laboratory. Massachusetts Institute of Technology. Retrieved 2016-05-26.
  3. "CLU files, 1976–1989". Tapes of Tech Square (ToTS) collection, MC-0741. Department of Distinctive Collections, Massachusetts Institute of Technology. swh:1:dir:5dc935d1c236b15a99b0750cf236b2d89ec951d0.
  4. Ushijima, Tetsu. "clu2c". clu2c. woodsheep.jp. Retrieved 2016-05-26.
  5. 1 2 3 Stroustrup, Bjarne (1996). A History of C++: 1979--1991. New York, NY, USA: Association for Computing Machinery. p. 699–769. Retrieved 25 March 2022.
  6. Lundh, Fredrik. "Call By Object". effbot.org. Archived from the original on 23 November 2019. Retrieved 21 November 2017. replace "CLU" with "Python", "record" with "instance", and "procedure" with "function or method", and you get a pretty accurate description of Python's object model.
  7. 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.
  8. 1 2 Liskov, Barbara (1992). "A history of CLU". The second ACM SIGPLAN conference on History of programming languages.
  9. Liskov, Barbara; Zilles, Stephen (1974). "Programming with abstract data types". Proceedings of the ACM SIGPLAN symposium on Very high level languages. pp. 50–59. CiteSeerX   10.1.1.136.3043 . doi:10.1145/800233.807045.
  10. 1 2 3 Liskov, B.; Snyder, A.; Atkinson, R.; Schaffert, C. (August 1977). "Abstraction mechanisms in CLU". Communications of the ACM . 20 (8): 564–576. CiteSeerX   10.1.1.112.656 . doi:10.1145/359763.359789. S2CID   17343380.
  11. Barron, D. W.; Buxton, J. N.; Hartley, D. F.; Nixon, E.; Strachey, C. (1963). "The main features of CPL". Computer Journal. 6 (2): 134–143. doi: 10.1093/comjnl/6.2.134 .
  12. Ierusalimschy, R.; De Figueiredo, L. H.; Celes, W. (2007). "The evolution of Lua" (PDF). 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.
  13. "Ruby's Roots and Matz's Leadership". Appfolio Engineering. 2019-11-08. Retrieved 2019-11-15. Matz feels that blocks are the greatest invention of Ruby (I agree.) He got the idea from a 1970s language called CLU from MIT, which called them 'iterators'...
  14. "Functional Programming HOWTO — Python 3.8.3 documentation". docs.python.org. Retrieved 2020-05-25.