<<

Peer to Peer Editor: Li Gong • [email protected] Post-Javaism

Andrew P.Black • OGI School of Science & Engineering, Oregon Health & Science University

he Java ogy — that one period or movement fol- Modernism in has been a phenomenal success. lows another in time — but also a Programming Language Design TIt’s a significant improvement change in direction or philosophy. Post- It is , not Java, that provides over C and C++, and its libraries for modernism, for example, is a reaction an analog to architectural modernism. network and GUI programming have against modernism’s established princi- Smalltalk was a sparse, simple language introduced large numbers of program- ples. Similarly, the call for participation with few unnecessary features; its form mers to previously esoteric disciplines. to the ECOOP workshop effectively was unconventional but functional. But Java isn’t the end of programming defines post-Javaism as a reaction continued on p. 93 language history. What language will against Java’s established principles. we use 10 or 20 years from now? In architecture, the modernists used Although good news for most pro- scientific principles to create stark, grammers, Java has been a mixed functional designs that flouted con- blessing for programming language vention. Architectural modernism’s researchers. On the positive side, Java defining moment was the 1958 con- has demonstrated that a quality lan- struction of the Seagram building in guage can make complex program- New York (see Figure 1). With its func- ming tasks much simpler: it shows that tional, clean, and simple lines, it language design is still a relevant dis- quickly became one of the US’s most cipline. On the negative side, Java’s architecturally influential office build- success has made obtaining support for ings. With its ethos captured in phras- research into new languages — and es that have passed into our cultural  publishing the results of that research heritage (think “less is more” and 2004 Andrew P.Black. Used by permission. — more difficult. The effect is that “form follows function”), modernism Figure 1. Seagram building, New York. object-oriented language research became the dominant style of the Modernism: less is more. focuses on fixing Java’s trouble spots 1960s and 1970s. or extending it to provide missing In Complexity and Contradiction in functionality. These are not bad activi- Architecture (1966), Robert Venturi ties, but they are necessarily limited to responded with a definition of post- Java-like languages: statically typed, modernism. He celebrated the rich mix class-based, single-inheritance lan- of historic styles found in great cities guages with a weak notion of interface. such as Rome and observed that many The recent European Conference for people find this complex, sometimes Object-Oriented Programming (ECOOP) contradictory, mix more comfortable included the Workshop on Object-Ori- than stark minimalism. That said, ented Language Engineering for the postmodernism is not a return to clas- Post-Java Era at which researchers sical architecture; rather, it takes clas- gathered to examine languages that sical elements and uses them in incon- diverge from this model. gruous ways. The AT&T building in  New York, which incorporates classi- 2004 Andrew P.Black. Used by permission. What is Post-Javaism? cal arcades and a pediment reminis- Figure 2. AT&T building (now Sony The prefix “post” is used in art and cent of a Chippendale highboy, is a Plaza). Postmodernism: using classical architecture to indicate not just chronol- defining example (see Figure 2). elements in inconguous ways.

96 JANUARY • FEBRUARY 2004 Published by the IEEE Computer Society 1089-7801/04/$20.00 © 2004 IEEE IEEE INTERNET COMPUTING Post-Javaism

continued from p. 96 its strength. Is this just coincidence, or architecture. New technology is the Indeed, “form follows function” de- do similar forces shape the evolution most obvious: type inference, parser scribes Smalltalk well. Smalltalk reject- of both architectural styles and pro- generators, garbage collection, large ed established conventions, such as stor- gramming languages? and inexpensive memories, peephole ing programs in files, using lots of optimizers, just-in-time compilers, and keywords, declaring types for identifiers, Evolution in Architecture advances in raw hardware speed have and sprinkling everything with paren- Four major forces have shaped archi- changed languages in ways that For- theses regardless of necessity. Instead, tecture’s evolution: technology, eco- tran’s designers could not conceive. Smalltalk embraced an architectural nomics, function, and fashion. Layered over this is the effect of model of amazing purity: everything New technology leads to structures economics. Computation is a young was an object, from classes to closures, that were never before possible: field, but we’ve already seen it progress dictionaries to methods, messages to dressed stone arches, cast-iron facades, from a dozen programmers sharing a numbers. Everything that supported the reinforced concrete, steel girders, plate $100,000, room-sized computer to language — compilers, browsers, execu- glass, mechanical ventilation, insula- dozens of smaller computers compet- tion contexts, debuggers — was an tion, engineered wood products — the ing for the attention of a $100,000 object, too. Less was more. list goes on. Simultaneously, econom- programmer. The result was breathtaking: a ic changes help one technology Although each of those smaller palace that seemed to defy gravity and advance as another recedes. Large computers is a thousand times more certainly challenged conventional wis- plate-glass windows, for example, powerful than one of the old room- dom. Smalltalk provided the seed that were once the prerogative of the fabu- sized machines, our languages are still blossomed into many of the past 30 lously wealthy; the rest of us had to be designed as if the computer’s time years’ innovations, including Java, content with arrays of small panes were more valuable than the program- graphical interfaces, programming in divided by mullions. The situation mer’s. A similar revolution has oc- the debugger, and contextual menus. today is reversed: large expanses of curred in the economics of memory, However, most of the tourists who glass are inexpensive, and we must but perhaps with a more obvious came to admire this modernist palace pay extra for true divided lights. effect: most of us program as if mem- went back home to their Victorian row New functions are another major ory were free, which indeed it is — houses. Only a few visionaries felt they source of innovation. The Romans did until it runs out. could live there. not build railway stations, and the Vic- These changes have made garbage torians did not build multistory park- collection and virtual machines the Java as Postmodernism ing structures. Each new function cat- norm, instead of esoterica of the Taking the analogy to architecture one alyzed the creation of new forms, and research laboratory. Technology and step further, we can say that Java often of the technology that made economics have enabled us to take one defined postmodernism. It celebrated the these forms possible. step away from the raw hardware — mix of styles in historic bodies of code Finally, we can’t underestimate fash- but only one step. and blended classical elements such as ion’s importance. The powerful display The demand for increased function- bytes, Bools, and curly braces with the their wealth by creating new fashions; ality has forced a minority of language functional modernist forms of objects the rest of us often have the urge to fol- designers to look seriously at declara- and instance variables. It gave people low them. I won’t try to explain fashion, tive notations like SQL, used for defin- back the conventions that made them but denying that it’s a powerful force for ing searches over databases, and feel comfortable — along with a healthy change would be foolish. HTML, used for defining Web pages. dose of complexity and contradiction. The result of these forces has pushed Others work with languages that don’t The result was that people liked architecture toward larger, more open even have names: their sentences are Java. They didn’t just visit on Sunday buildings, with such huge oscillations sequences of gestures and clicks in a afternoon tours: they gave up their about the mean that this trend user interface. Approximately 95 per- Victorian row houses and moved in. becomes apparent only decades or cent of all the people who program Java represented not innovation, but centuries later. Will the same be true computers today use these or other consolidation. for programming languages? domain-specific languages. Of course, the remaining 5 percent — people, like The Forces of Evolution Evolution in us, who read IEEE Computer Society I don’t have enough space to pursue Programming Languages publications — realize that these aren’t the architectural analogy too much The forces that effect programming “real” languages at all, and that the further, but I’m constantly surprised by languages are similar to those in programmers who use them aren’t

IEEE INTERNET COMPUTING www.computer.org/internet/ JANUARY • FEBRUARY 2004 93 Peer to Peer

“real” programmers. We’ve even 1970s. I can’t find anything in Ingall’s opment; Java has not been able to do coined a separate name for them: users design principles paper that argues this yet, despite the valiant efforts of (or sometimes, lusers).1 This catego- against type declarations.3 In fact, Object Technology International and rization is similar to the way that when we designed Emerald in the VisualAge for Java. Because Smalltalk “real” architects recognize that food early 1980s, we had to invent a type represents programs as objects instead processing plants, fabs, bridges, and system that was adequate for letting of files, tools are amazingly easy to municipal housing projects aren’t programmers define their own build. As good tools become available architecture at all, but mere engineer- List.of[something] data types.4 to the community, they become step- ing. Yet it has led to a situation in So why do I now believe that type ping-stones to even better tools, and which “real” programming languages declarations are a mistake? Let’s look the process accelerates. are very poor at describing 95 percent at a fragment from a Java program The disadvantage of Smalltalk’s of what computers do. that plays a card game:5 easy access to metaprogramming is Because of our propensity to ignore that it’s too easy to use reflective new technology and to keep out public DiscardPile discardPile; operations “by accident.” Java’s solu- domain-specific function, fashion has ... tion is to label some interfaces as had a disproportionately large effect discardPile = part of a reflect package. The on programming language design. new DiscardPile(268, 30); Strongtalk language did something Because fashion tends to be cyclic, we more sophisticated: to perform a can reliably predict that the trend will Now consider the following conceptu- reflective operation on an object, it swing away from postmodernism and ally equivalent Smalltalk code: required you to first obtain a mirror back to something that looks a lot on that object and then reflect on the more like modernism. In other words, instanceVariableNames: mirror.7 This makes the distinction the next post-Java language will look ‘... discardPile ...’ between reflective and ordinary oper- a lot like Smalltalk. ... ations quite clear. I think we can take discardPile := this idea a bit further and use colored The Smalltalk Revolution DiscardPile locatedAt: 268@30. types to distinguish between the Rather than just repeating history, we results of reflective and ordinary should study it; rather than just going The redundancy in type name, class operations. For example, the result of back to Smalltalk, we should learn name, and instance variable name in counting the number of classes from it. How can we repair Small- the Java just clutters the code without between a given class and the root of talk’s weak points without diluting its adding any extra information. We now the hierarchy might be a red integer, strengths? have the technology to infer most as opposed to an ordinary white inte- variables’ types and present them ger. The sum of a red and a white Small is Beautiful unobtrusively in a programming tool integer would also be red; we could One of the great strengths of Smalltalk when requested. In fact, Haskell and use this scheme to ascertain, by is that it’s small — really small. The ML have done this for years. Let’s examining their colors, which results Blue Book’s syntax diagrams define 27 admit that — when supported by prop- depend on reflection. syntactic categories for Smalltalk, er browsing tools — inference is a bet- You might ask why it’s important to compared to 31 for Pascal.2 This ter technology, adopt it and move on. be able to delimit the effects of reflec- includes cascades, symbols, and array tive operations in this way. The answer constants, which I think I would take Reflection is that refactoring is one of our most out if I were designing Smalltalk Another great thing about Smalltalk, powerful tools in the constant battle today. Small is beautiful. which the Java folks seemed to miss at against entropy.8 In general, One thing I used to consider first, is that the programming environ- refactorings are semantics-preserving Smalltalk’s greatest shortcoming, I ment is fully accessible from the lan- only in the absence of reflection. To now believe to be one of its strengths: guage. Smalltalk is, in fact, a metapro- see this, consider a program that uses the absence of type declarations. I gramming system: through the reflection to obtain the name of an think the principal reason for this wonders of computational reflection, instance variable, extracts the fifth and omission was not that the designers you can access and change the sys- the seventh letters, converts them to were philosophically opposed to get- tem’s internals from within the system ASCII codes, and prints their product. ting early warnings of programming itself.6 Smalltalk had the advantage of Clearly, changing the name of that errors, but rather that the technology casting off the boat anchor of a file- instance variable will change the to check them didn’t exist in the based representation early in its devel- behavior of the program, or even cause

94 JANUARY • FEBRUARY 2004 www.computer.org/internet/ IEEE INTERNET COMPUTING Post-Javaism

it to crash if the new name is only six Failure security are two of the biggest problem characters long. Thus, we see that it is The defining characteristic of distrib- areas, and language designers are important for the program maintainer uted computation on the Internet is indeed working to create language fea- to know when it is safe to make what partial failure: part of the program tures, such as universally quantified is usually a harmless change, such as fails to satisfy its specification, while assertions and security types, to help renaming a variable, and when it other parts continue to function. address these problems. Perhaps, just as might have unexpected consequences. Failures are distinguished from code safety in the Internet was the killer exceptions in that the latter are part problem that lead to Java’s adoption, Distribution of the interface specification. Thus, a the next language for the Internet might I’ve argued that although programs are procedure that generates an excep- be driven by the need to improve soft- called on to perform vastly more, and tion condition might be fulfilling its ware quality and security. more varied, functions than anyone specification. could have dreamed of 20 years ago, Because a failure’s exact nature is Acknowledgments many of these functions are now the outside the scope of the specification, I am indebted to Richard Staehli, for fruitful dis- province of domain-specific languages. recovery requires us to pick over the cussions about programming languages, and Jes- One functional category that isn’t is failed computation’s debris to see what, sica Black, for invaluable information about distributed programming. This is if anything, we can salvage and what architecture. This article is a revised and extended because it is really a metacategory. cleanup is necessary. Only a program version of a position paper originally submitted One approach to distributed pro- that has not failed can accomplish this to the ECOOP Workshop on Object-Oriented Lan- gramming is to do what Emerald did: task. Thus, we need some kind of guage Engineering for the Post-Java Era. identify a particular programming par- watertight compartment that gives us a adigm suitable for distribution (in this dry place to stand while trying to pump References case, mobile objects) and support it in the water out of the failure. Operating 1. E.S. Raymond, ed., The New Hacker’s Dic- tionary, 3rd ed., MIT Press, 1996. the language. This works well if that systems provide such compartments — 2. A. Goldberg and D. Robson, Smalltalk-80: paradigm matches the application, but address spaces — but language design- The Language and Its Implementation, Addi- badly otherwise. ers have heretofore ignored them. The son-Wesley, 1983. Another approach is to provide Internet programming language of the 3. D.H. Ingalls, “Design Principles Behind libraries that support a variety of para- 21st century would do well to provide Smalltalk,” Byte, vol. 6, no. 8, 1981, pp. 286–298. digms; this works particularly well if for failure recovery. 4. R.K. Raj et al., “Emerald: A General Purpose the language is sufficiently reflective. Programming Language,” Software-Practice For example, suppose we want to Post-Post-Java & Experience, vol. 21, no. 1, 1991, pp. 91–118. implement an object-oriented message The only way to produce a language 5. T. Budd, Understanding Object-Oriented Pro- send to remote objects. Suppose further over which one programmer can have gramming Using Java, Addison-Wesley, 2000. that rather than stepping outside of the intellectual mastery is to start with a 6. F. Rivard, “Smalltalk: A Reflective Lan- language and resorting to a preproces- really tiny kernel and add on what 30 guage,” Proc. Int’l Conf. Metalevel Archi- sor, we prefer to implement this feature years of experience has shown to be tectures and Reflection (Reflection ’96), in the language itself. This means that absolutely necessary. Even then, we 1996, pp. 21-38. the language’s metalevel features must must be prepared to learn that our 7. L. Bak and G. Bracha, “Mixins in Strongtalk,” presented at the Inheritance Workshop, be sufficient not just to reify messages experience was inapplicable to the European Conf. Object-Oriented Program- and argument lists, but also to inter- changing environment in which we ming (ECOOP), 2002; www.cs.ucsb.edu/ cede to change their semantics. work. We know that the opposite projects/strongtalk/pages/documents.html. Mobile objects present a more com- approach does not work: it is not pos- 8. A. Hunt and D. Thomas, The Pragmatic Pro- plex example: implementing mobility sible to start with a large language grammer, Addison-Wesley, 2000. as a library requires access not only to and identify features to remove, the implementation of message send because the features are invariably Andrew P. Black is a professor of computer sci- but also to the underpinnings of the interdependent. ence at the OGI School of Science & Engi- object storage subsystem. For efficien- In addition to the fairly well-under- neering, Oregon Health & Science Universi- cy, mobility also requires that the dis- stood additions I have described here — ty. His research interests include distributed tinction between mutable and im- failure-handling, distribution, reflection, systems, programming languages, and pro- mutable objects be manifest in the and immutability — other additions that gramming methodology. He received his language, and that the language does address serious issues in Internet com- D. Phil from the University of Oxford. He is not provide an object-identity opera- puting are certainly worthy of consid- a member of the ACM. Contact him at tion as a primitive. eration. Today, software quality and [email protected].

IEEE INTERNET COMPUTING www.computer.org/internet/ JANUARY • FEBRUARY 2004 95