Object-Oriented Programming: Regaining the Excitement
Total Page:16
File Type:pdf, Size:1020Kb
Ob ject-Oriented Programming: Regaining the Excitement Andrew P. Black Oregon Graduate Institute of Science & Technology Portland, Oregon, USA [email protected] Abstract. This pap er is based on a sp eech delivered at the ECOOP'98 Conference Banquet. It is not a literal transcription of my talk, since no recording was made, but has b een reconstructed ex post facto based up on my sp eaker's notes and my memory.Ihavealsotaken the opp ortunity to add some headings and references. Distinguished Chairmen, Memb ers of the Conference Committee, Represen- tatives of the sp onsoring organizations, distinguished Professors, conference par- ticipants, and friends: Go o d evening. It's customary to start this kind of talk with a joke, at least in part to give the audience a chance to b ecome accustomed to my strange accent b efore I start to sayanything interesting, but I'm going to skip that tonight b ecause I think that wehave already heard quite enough jokes for one evening. To set the record straight from the very rst, I should make it clear that I do not work for IBM, nor haveIworked for IBM in the past. Although I did once sp end a very enjoyable year at IBM's Yorktown Heights Research Lab oratory, IBM was very clear that I didn't work for them, even though I did turn up every day and they did pay me: I b elieve that the distinction had something to do with so cial security tax or health insurance. I should also p oint out, particularly for the b ene t of those of you around the corner who cannot see me, that yes, I am wearing a tie, but no, I don't use a mainframe. I used to use a mainframe, but one day the mainframebrokeand all of the little b eads came o . [At this p oint the reader will have to imagine a large broken abacus frame with b ent wires and missing b eads.] 1 Inventing the Future of Ob ject Technology The right thing to do in a talk of this nature is to predict the future of ob ject technology, but prediction is hard, and predicting the future is esp ecially hard! Alan Kay once said: \The b est way to predict the future is to inventit".And he was remarkably accurate. Let me read you a quote from over 20 years ago. In the 1990's there will b e millions of p ersonal computers. They will b e the size of noteb o oks of to day,have high resolution at screen re- ective displays, weigh less than 10 p ounds, have 10 to 20 times the computing and storage capacity of an Alto. Let's call them Dynab o oks. The purchase price will b e ab out that of a color television set of the era... Though the Dynab o ok will have considerable lo cal storage and do most computing lo cally, it will sp end a large p ercentage of its time ho oked to various large, global information utilities which will p ermit communication with others of ideas, data, working mo dels as wellasthe daily chit-chat that organizations need in order to function. This is from Alan's pap er \The Early History of Smalltalk"[5], in which Alan quotes an internal XeroxPARC memo from around 1976. I recommend that pap er most highly: if you nd any wisdom in my remarks this evening, please attribute it to Alan Kay and not to me. My goal tonightistochallenge you to put the excitementbackinto ob ject- orientation, and to recapture some of the dynamism of those early Smalltalk days. Is this p ossible? Or has ob ject-orientation b ecome like structured program- ming: the right idea, but no longer the fo cus of innovation, exactly b ecause everyone is already doing it. For example, wedon'thave a Europ ean Conference on Structured Programming every year. I don't think that ob ject-orientation is yet at that p oint. There are still many hard problems to solve: scale and encapsulation are two that I will mention brie y tonight. 2 Programming Language Contributions Relevantto Ob ject-orientation The programming language researchcommunity has historically b een a great source of innovation. I b elievethatwe should challenge ourselves to recapture that atmosphere of innovation; to help us on our way, I will takeabrieflookat some of the ideas that have b een \brought to market" byin uential programming languages over the last fortyyears. I'm not claiming that the listed languages invented the concepts in every case, but rather that these languages were among the rst to p opularize them. 2.1 Lisp (late 1950s) Lisp was a startling language for its time: I b elieve that Lisp is one of Alan Kay's \almost new things". It contributed: { heap allo cation and garbage collection, { interpreted execution, and { conditional expressions. 2.2 Algol 60 Another \almost new thing", in contrast to the \b etter old things" of COBOL and FORTRAN. Its contributions include: { a semi-formal, concise de nition, { grammars as a descriptivetechnique, { blo ck structure, { recursion|but not the word \recursion"; - recursion intro duced the distinction b etween program text (or \static instance") and its execution (or \dynamic instance"). This distinction is the kernel of the idea that b ecame Simula Ob jects [7]. Algol 60 also intro duced { declarations, { call-by-name, { \own" variables, { the extension of the concept of expression to non-numeric values, - Bo olean expressions, and - \designational expressions", and { the idea of \Security", whichwewould probably to day call semantic in- tegrity. Security is the principle that a program must either b e rejected as incorrect by compile-time or run-time checks, or its behavior must be understandable by reasoning basedentirely on the language semantics, indep endent of the imple- mentation [2, 7]. However, no language is p erfect. Two \non-contributions" of Algol 60 were: { that the non-numeric expressions that Algol 60 chose to include were lab els, not pro cedures; and that { input/output was relegated to a library. 2.3 Algol W, Pascal and Simula 67 Contributions: { quasi-parallel execution (previously intro duced in Knuth's SOL); { user-de nable typ es; { static inheritance (Simula's pre x classes); { use of pre x classes to provide \language dialects" { Sum typ es, also known as varianttyp es, or discriminated unions; { the combination of data and op erations in a single language construct; and { the idea that binding of a value to a name requires only typ e compatibility, not typ e identity. Non-contributions: { Explicit reference variables, and { Pascal's sacri ce of the security of Algol 60 bythevariant record construct. This last innovation is p erhaps one of the reasons that Tony Hoare said of Al- gol 60: \here is a language so far ahead of its time, that it was not only an improvement on its predecessors , but also on nearly all its successors"[2]. 2.4 Algol 68 Contributions: { uni cation of statement and expression, that is, making the distinction b e- tween them one of typ e, rather than one of context-free syntax; { the void typ e; { co ercion; { environment enquiries; { conceptual minimality, for example, - the use of references to eliminate the notion of variable, and - the use of pro cedures to eliminate call-by-name; and { obtaining an extensible syntax|then an imp ortant goal|by means of the de nition of new op erators, and by that means alone. Non-contributions: { 2-level grammars as a descriptive technique, and { once again, breaching security,thistimeby requiring that the programmer not exp ort a stack-allo cated variable outside of its scop e, which is not some- thing for which implementations can easily check. 2.5 CLU, Alphard, Mo dula (1974-78) Contributions: { encapsulation, { named scop es (i.e., the mo dule concept), { parametric p olymorphism, and { F-b ounded p olymorphism (CLU's where clauses) - but it's not clear that the CLU designers realized at the time what they had invented. 2.6 Emerald (1984-6) Contributions: { safe, static subtyping, { F-b ounded p olymorphism (in the interpretation of conformity in where clauses)[4] - but we also did not yet knowthatitwould b e given this name, { mobile ob jects, { lo cation-indep endentinvo cation, { ob ject constructors (which I b elieve are relevant to Ole Lehrmann Madsen's quest to integrate prototyp e and class-based programming styles), { separation of typ e from implementation, and { the \op en world" assumption This last is the idea that new ob jects and new classes (sup erclasses as well as sub classes) can b e added to a system at any time, so that we don't havetoshut down and recompile the internet. 2.7 Later Developments What has happ ened since then? { multi-paradigm languages (LIFE, Leda, etc.) { higher-order functional languages with ob ject-oriented concepts (Ob jective CAML, Haskel with its typ e classes, etc.) These are interesting, but not earth-shaking. And then, of course, wehaveJava. What are Java's advances over Emerald? The ma jor one is of course replacing word pair brackets (like do ... end)with curly braces fg, but we should not overlo ok typ ed byte-co de and byte-co de veri cation. The latter means that one can obtain a class that someone else has compiled and b e sure that it is typ e-safe. This is a real advance, although pro of-carrying co de [6] maywell b e a more elegant and more widely applicable wayofachieving the same e ect.