编程范型 | 多范型: 面向对象, 过程式 |
---|---|
設計者 | 芭芭拉·利斯科夫和她的学生 |
實作者 | 麻省理工学院 |
发行时间 | 1975年 |
型態系統 | 强类型 |
網站 | www |
主要實作產品 | |
Native CLU[1], Portable CLU[2], clu2c[3] | |
啟發語言 | |
ALGOL 60, Lisp[4], Simula[5] | |
影響語言 | |
Ada, Argus, C++, Lua, Python[6], Ruby, Sather, Swift[7] |
CLU是一门编程语言,由芭芭拉·利斯科夫和她的学生在1974年到1975年于麻省理工学院(MIT)创造。虽然它没有被广泛使用,但它引入了抽象数据类型[8],和许多现在广泛使用的特性,而被视为面向对象编程发展的重要一步。
主要贡献还包括:传共享调用、迭代器、多值返回(并行赋值形式)、参数化类型和可变类型。值得注意的是它使用了具有构造器和方法的类,但没有继承。
CLU looks like an Algol-like language, but its semantics is like that of Lisp: CLU objects reside in an object universe (or heap), and a variable just identifies (or refers to) an object. We decided early on to have objects in the heap, although we had numerous discussions about the cost of garbage collection. This decision greatly simplified the data abstraction mechanism ……. A language that allocates objects only on the stack is not sufficiently expressive; the heap is needed for objects whose sizes must change and for objects whose lifetime exceeds that of the procedure that creates them. …… Therefore, the choice is: just heap, or both. ……
One unusual aspect of CLU is that our procedures have no free (global) variables ……. The view of procedures in CLU is similar to that in Lisp: CLU procedures are not nested (except that there can be local procedures within a cluster) but instead are defined at the "top" level, and can be called from any other module. In Lisp such procedures can have free variables that are scoped dynamically, a well-known source of confusion.
Programming languages that existed when the concept of data abstraction arose did not support abstract data types, but some languages contained constructs that were precursors of this notion. …… The mechanism that matched the best was the class mechanism of Simula 67. A Simula class groups a set of procedures with some variables. A class can be instantiated to provide an object containing its own copies of the variables; the class contains code that initializes these variables at instantiation time. However, Simula classes did not enforce encapsulation ……, and Simula was lacking several other features needed to support data abstraction, …….
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.
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.