Sun Java Solaris Communities My SDN Account Join SDN
 
Article

Growing a Language: A Conversation with Guy Steele

 
Guy Steele
Guy Steele


by Janice J. Heiss
May 1, 2003

Guy Steele, a Sun Fellow at Sun Microsystems, is responsible for research in language design and implementation strategies, architectural and software support, and for the specification of the Java programming language. The recipient of many awards, he has a Ph.D. in computer science from MIT, has authored or co-authored five books and many articles, and has contributed to the specifications for several other programming languages, including C, Fortran 90, High Performance Fortran, Common Lisp, Scheme, and ECMAScript. His recent research focus includes such diverse areas as network design for processor clusters, circuit designs for floating-point arithmetic, and proposals for improvements for the Java programming language, such as generic types, operator overloading, and constant classes.

question You have written that "a language design can no longer be a thing. It must be a pattern -- a pattern for growth - a pattern for growing the pattern for defining the patterns that programmers can use for their real work and their main goal." You said that a good programmer does not just write programs, but engages in language design, building on the frame of a base language. Could you elaborate on this?

answer Sure. Every time you write a new function, a new method, and give it a name, you have invented a new word. If you write a library for a new application area, then the methods in that library are a collection of related words, a new technical jargon for that application domain. Look at the Collection API: it adds new words (or new meanings for words) such as "add", "remove", "contains", "Set", "List", and "LinkedHashSet". With that API added to Java, you have a bigger vocabulary, a richer set of concepts to work with.

Some concepts are more powerful, more general, more widely used than others -- "liberty" and "mortgage" are more widely used than "belly button ring" or "faucet wrench". But every new word, every new meaning, every new idiom enriches the language.

question You have argued that we need to put tools for language growth in the hands of developers. With regard to the Java language, how is this currently happening and how might it happen in the future? How should the Java language grow, given its current condition?

You once said that it would be a good thing for the Java language to add generic types and let the user define overloaded operators. What progress has been made on this? What more rules are needed at this juncture?

answer Generic types are slated to be added in Java 2 Standard Edition, (J2SE) release 1.5. This is a most important tool for language extension. In the technical jargon of language designers, generic types provide abstraction over types, allowing you to compute a type from another type. But forget all that. The simple way to say it is that if you have a vector and you want it to hold strings and nothing else, generic types let you say that, and the compiler can check it. You just say "Vector<String>" and if you ever try to stick a Thread or a BigDecimal into that vector, the compiler tells you right away. You don't have to wait until you get a nasty exception at runtime to find the bug in your code.

Overloaded operators are still a subject of controversy. They are almost indispensable for certain kinds of mathematical work, but people who oppose adding them to the Java language point out, quite rightly, that the feature was badly abused in C++ for nonmathematical purposes, making code much harder to read than necessary. Most Java applications are nonmathematical in nature. One could make a good argument that commercial applications have no need for operator overloading, except that commercial applications do use (or should use) BigDecimal arithmetic, and it would be really nice to be able to use + and - and * and / with BigDecimal numbers. Much the same can be said of so-called "lightweight classes": their greatest value would lie in supporting numerical concepts such as complex numbers and interval arithmetic.

"We have an interesting decision to make that is more a political or business question than a technical one: should the Java language be extended to support the needs of mathematical applications?"

- Guy Steele, Sun Fellow, Sun Microsystems

We have an interesting decision to make that is more a political or business question than a technical one: should the Java language be extended to support the needs of mathematical applications? If so, then I would argue strongly for introducing operator overloading and lightweight classes -- I'm pretty sure such facilities would also get used for other purposes. If not, then maybe we should just make + and - and * and / work for the BigInteger and BigDecimal classes as a special case, much the same way that + is already a special case for the String class.

question If you could wave a magic wand and get 10,000 talented Java technology developers to do whatever you wished, what would it be?

answer How about "invent the new killer app that will get the economy going again"? That might take only one developer, but to get that one success maybe you need to have 10,000 developers try.

Aside from that, I don't think I'm here to tell Java developers what to do. I want them to tell me what to do. I'm a tool-builder, a tool designer, and I need to know what developers would find useful. (Before I get swamped with email, let me note that my expertise is in the base language itself, not the libraries and APIs!)

question In what ways would it be a mistake for the Java programming language to grow? What are some pitfalls? What are the wrong directions it could take?

answer Well, to be very abstract about it, every time you grow a language, you increase the total number of text strings that are correct programs. It's important to keep the correct programs at some distance from each other, so that mistakes are less likely to turn one program into another correct program that isn't the one you wanted.

So, for example, I think it would be a mistake to extend the language to the point that

for (int i=0, i<n, i++) System.out.println(i);

would be considered correct code, even if I had some very clever reason why using commas instead of semicolons could convey some useful twist, because it would be too easily confused with the usual

for (int i=0; i<n; i++) System.out.println(i);

Also, there is power in knowing that there are some things that you just can't say in a language. It's really helpful to a programmer to know that, for example, local variables are effectively "private" and so another method can't unexpectedly alter the value of a local variable. It's such a valuable principle that I think it would be a bad idea to extend the language to allow methods to access each other's local variables.

Designing a good programming language isn't just a matter of throwing together a set of features; it's a matter of establishing important principles that the programmer can rely on. It's important to follow those principles as a language is extended. Sometimes the principles themselves can be extended, but only with great care. Here are four examples of important principles in the Java language: local variables are private, you can't violate the type system, the evaluation order goes from left to right, and the "equals" method is symmetric and transitive.

question To what do you attribute the success of Java technology?

answer Both push and pull. Sun put a lot of effort behind Java technology development and marketing, but it wouldn't have gotten anywhere if it hadn't filled a huge need. The Java programming language provided a way to program the Internet. It had a good security story, it was close enough to C++ that it was easy to switch, it provided great APIs for user interfaces, making network connections, talking to browsers, and organizing business applications. It was what people needed to make e-commerce happen.

question Tell us about your first encounter with Java technology.

answer Well, this part is embarrassing. When I first joined Sun Labs in 1994, I surveyed the existing projects to see what was going on. One of the projects involved a variant of C they called "Oak," and it seemed to be focused on a narrow application area, set-top cable boxes. "Interesting, I guess, but not earth-shaking," I said to myself as I tossed the overview on my pile of project documents. "Next!"

Little did I know. A year later, Bill Joy called me up and said, "Its new name is 'Java,' and we think it's going to be a big deal. Help me write the language specification!" And it did turn out to be a big deal.

This reminds me of an earlier incident when Larry Smarr, who directs the National Computational Science Alliance, first told me, over lunch, about an amazing new technology called the "World Wide Web" and interactive file browsers. I was skeptical then, too, but a year later I told him, "I was wrong, you were right!"

I was born in Missouri, the "Show Me" state, so maybe I do take a little bit of convincing. The one virtue I will claim is that I don't get stuck on my first impression. I keep an open mind and am ready to jump on board when the time is right. And once I'm on board, I am really tenacious about working out the nit-picking details and corner cases until everything is just right.

See Also

Coding from Scratch
(http://java.sun.com/features/2003/01/lanier_qa1.html)

The Future of Virtual Reality
(http://java.sun.com/features/2003/02/lanier_qa2.html)

The Poetry of Programming
(http://java.sun.com/features/2002/11/gabriel_qa.html)

end.