Wednesday, July 1, 2009

2009 JavaOne: Project Coin

I have enjoyed reading some of the 2009 JavaOne presentations since they have been made available online. One of the presentations I was most interested to read was Joseph Darcy's Small Language Changes in JDK Release 7: Project Coin (TS-4060). I have blogged on Project Coin previously, but am using this blog post to summarize some of the things I found most interesting about this JavaOne presentation.

Improved Dynamic Language Support on the JVM

Scripting languages on the JVM have begun to really gain traction in terms of popularity and use. One of Darcy's first slides mentions JSR 292 ("Supporting Dynamically Typed Languages on the Java Platform"), which proposes a new bytecode called invokedynamic and additional support for easier implementation of dynamic languages on the Java Virtual Machine.

Improved Modularity

The presentation also has a slide focusing on the desired improved modularity expected for Java SE 7. This was a popular topic at 2009 JavaOne as evidenced by the presentations on it (such as the one on Project Jigsaw) and by the Mark Reinhold quote "The classpath is dead." This actually is a very significant change, but it is briefly covered in this presentation.

The Elvis Operator

One of the "small features" covered in this presentation is the so-called "Elvis operator," a more concise version of the ternary operator. I find myself missing some of the features of Groovy when using traditional Java and this would be one operator that I could use in both languages if it was added. The "Elvis" operator is handy for specifying a default value that can be used when the evaluated expression is null. Like Groovy's safe navigation operator, it is a concise way to specify how to avoid unnecessary nulls. I have blogged previously about how I like to avoid the NullPointerException.

Switch on String in Java

Joe Darcy is a submitter of the proposal to add the ability to switch on String in Java. I have blogged previously regarding this versus the ability to switch on String in ActionScript. Although I find myself missing the ability to switch on a String in Java less now with the fantastic Enum and polymorphism, there are still situations I run into (often when using third-party libraries) where it would be nice to switch on a String.

Better Exception Handling

A slide in this presentation covers the proposed improvements to exception handling to allow a single catch statement to catch multiple explicitly specified exceptions. This can be much nicer than repeating code in each individual exception catch block.

Other Small Language Features Being Considered

There are a few other potential new Java SE 7 language features covered in the slides of this presentation. They include automatic resource management, type inference ("Diamond"), and list and map literals.

On Selecting What To Include

Although it is interesting to see which small language change proposals are being seriously considered, perhaps the most interesting aspect of this presentation for me is the coverage of the many things that must be considered when weighing which options to add. Darcy talks in this presentation about the importance of thinking in the big perspective rather than with limited view of what would be nice. He has a slide titled "Greed is Not Always Good" and includes perhaps the most important point to keep in mind when thinking about what one would like in Java:

"Default response is to keep the language as-is. Burden is on the proposer to convince that a change gets in; burden is not to convince to keep a change out."

I also enjoyed Darcy's slides covering all the work involved in a language change above and beyond the implementation of the feature itself. He has an overview slide in which he demonstrates the many related artifacts that must be updated such as the Java Language Specification and updating the Javadoc output. Darcy devotes several slides to each of the artifacts that need updating and then really drives the point home by using the introduction of the enum as an example. I love the enum, but it is obvious that it needed to be really desired to justify the effort.

What's Not Going to be in Java SE 7

After making a compelling case for adequately comparing the value and benefit of a particular new language feature to the cost of its introduction, Darcy has a slide in which he highlights in red some popular new features that will NOT be going into Java SE 7. These are contrasted on the same slide with features first implemented in J2SE 5. What interests me about this slide is to see where features punted from Java SE 7 (closures, reification [my favorite], and properties) rank in terms of effort against features that were implemented with J2SE 5 (enums, autoboxing/unboxing, annotation types, and generics).

Keeping Up with Project Coin and Other Java SE 7 Developments

Because Java SE 7 is still clearly a work in progress, it is not surprising that one slide in the presentation warns about forward-looking statements in the presentation. We should all be aware that any of these mentioned changes may not actually end up in Java SE 7. I have found Alex Miller's Java 7 site to be my favorite one-stop shop for the latest news on Java SE 7 developments. He apparently scours the web and blogosphere for articles that he links there and writes his own blog postings and articles as well. He currently has the status of inclusion of many proposed features listed on his page ("YES" for still planned for Java SE 7, "NO" for explicitly punted from Java SE 7, or other status if not known for certain).

Other useful sources of information include Joseph D. Darcy's Weblog, the Project Coin web page, Danny Coward's Weblog, Mark Reinhold's Blog, Neal Gafter's Blog, and Stephen Colebourne's Weblog.

No comments: