Java SE Language: Eadem Mutata Resurgo\*
By dannycoward on Apr 14, 2006
Part of the reason working in the Java SE group is so interesting is the diversity of the developers using the technology. As developers, we're writing a wide variety of applications in a wide variety of different domains. Java SE may only be a part of the software stack we're depending upon. Often we're working with Java SE within a Java servlet, or EJB container. Java language changes are of special interest to us in the Java SE group, because wherever we are as a developer in the software stack, additional features we add to the language make a different to us all.
Curling the Chip
There was a story in The Economist a few years ago about innovation. I hate to paraphrase such a good article, but that grain of golden sand appears to have crept to the deep. One of the points was to contrast product innovation for new products and for established products. A wholly new product has no customer base. No commitments or expectations. The successful innovations tend to be big new ideas, or a disruptive application of an old idea in a totally new setting. Like the Sony Walkman was. Innovation for established products is arguably more difficult: you have customers who already like your product who you want to keep. There are teams of people building, delivering and selling your product that would be difficult or expensive to change. So your ability to innovate is much more constrained. But the article gave the example of a company making potato chips that were popular, but not popular enough. Rather than invent some wholly new potato based snack, they put a curl at the end of each chip. There was minimal disruption to their production processes. Customers didn't notice anything new till they opened the bag. There are two happy endings depending on your perspective. One happy ending is that people loved them because they could shovel more dip onto them. The other is that people loved serving them because there was less spillage of dip after the party was over. Either way, sales jumped dramatically.
Java SE Language Changes
So to some extent, with a successful technology like Java SE, good things to look for on the horizon are the metaphorical curls in the chip. Non-disruptive innovations that have widespread consequences. Given that many Java developers are Java EE developers, its no wonder that the use of annotations has been such a big hit. As Graham's been explaining, that curl in the chip has scooped up a big wobbling dollop of complexity out of the EE deployment descriptors and programming model.
Here's a selection some of the possibilities I've been thinking about. Doubtless you recognize some of them.
This would be a language syntax to support short handing the variable foo, getFoo(), setFoo() pattern. Definitely a pattern that is routine and dull to keep replicating by hand.
Writing and wiring event listeners is a frankly a bore. For example, implementing and wiring a button to call the updateLastName() method on your AddressBook object when clicked gets old if you have to do that kind of thing a lot.Wouldn't you prefer something like button.addDelegate(delegate updateLastName) and get it over with ?
A block closure is a group of statements defined within the context of...another group of statements. So block closures are statements within a statement ! (A Dream within a Dream. My entry found its theme.). Inner classes are the poor man's version of this: they are hobbled because the only thing they can do with local variables is read those that are final (why is that ?). Plus some people think they are plain ugly. Block closures could be an enormously powerful way make code very compact. But is there a syntax that pairs brevity with readability ?
Unlike the esoteric predecessor, this is just the ability to deposit the source code for a class in various different places, like separate files. The most familiar usages are by tools that auto-generate parts of a class for you, perhaps a GUI builder tool, leaving you to fill the rest out in fear of the warning comments bespattered around the source file. With a partial classes mechanism, the machine generated part could live safely in one file, and the bit you work on in another. Simple and tidy.
So I wonder which of these, or the many other potential language changes could be the next curl in the chip for Java SE 7 'Dolphin' ? And in particular, which could be used by the Java EE platform with powerful consequences ? And keep to our principles ?
\* So what's with the title this time ? Of course, Eadem Mutata Resurgo means "I shall arise the same, though changed" which is relevant to the topic. Plus my brother read my blog and gave me some typically fraternal feedback ('excruciating' was one word he used :-) ). So the title is also his college motto. You've got to throw the non-engineers a bone now and again.