Jazoon 2009 – Day 2

My today’s schedule was little bit more relaxed than yesterday. It started with a great keynote delivered by Danny Coward which evolved around new and noteworthy things we can expect in the coming JDK 7 and recently released JavaFX 1.2.

Maybe it’s just me, but I allways eagrly await what’s new in the upcoming JDK release. The things that I use to like most may sometimes seem subtle (such as new short syntax of a for loop introduced in JavaSE 5), but at the end of the day those are the things that really make my coding much more comfortable and my code shorter and thus easier to read.  So I guess my favorite features for the JDK 7 evolve around Project Coin, where “coin” stands here for a synonym of “small” or “subtle”, and such are the changes in the Java language this project introduces. To mention few:

Using Strings in case statements

With JDK 7 you are (finally) able to use Strings in case statements directly:

String color = "red"
switch (color) {
    case "red" :
        // do red stuff
    case "green" :
        // do green stuff
    case "blue" :
        // do blue stuff
        // do default stuff

Improved type inference

If you ever tried to really leverage generics in your code you soon ran into initializations like the one bellow:

Map<String, List<ItemClassWithSomeLargeName>> mapOfItems = 
            new HashMap<String, List<ItemClassWithSomeLargeName>>();

I always wondered why it is required to repeat the type information <String, List<ItemClassWithSomeLargeName>> in the constructor invocation. I was not alone aparently. Josh Bloch even suggested a possible elegant solution leveraging a factory method pattern.

Finally with JDK 7, the above code is a history, as JDK 7 lets us do the following:

Map<String, List<ItemClassWithSomeLargeName>> mapOfItems = new HashMap<>();

The ‘Elvis’ operator

Are you tired of biolerplate code related to null checks such as the next one?

public synchronized void countPageHit(String pageName) {
    Integer countVal = hitCounts.get(pageName);
    if (countVal == null) {
        hitCounts.put(pageName, 0);
    } else {
        hitCounts.put(pageName, ++countVal);

Well, call Elvis for help and he’ll let you do this instead:

public synchronized void countPageHit(String pageName) {
    // if there are no hit counts stored in the map,
    // use 0 as a current count value
    Integer countVal = hitCounts.get(pageName) ?: 0; 
    hitCounts.put(pageName, ++countVal);

Of course, there are other notable changes coming with JDK 7, such as modules to solve current visibility vs. accessibility issues, more work on letting dynamic languages to run as efficiently as possible in the VM, new and extended I/O APIs (new filesystem API, file notifications, directory operations, asynchronous I/O) and new “Garbage First” Collector very suitable for a wide variety of applications, to name a few.

As for the JavaFX 1.2, this latest release brings support of more platforms (* = new):

  • Desktop platforms (Windows, MacOS, Linux* (beta), OpenSolaris* (beta))
  • TV (a television from LG*)
  • Mobile Phones (Apart from the existing developer emulator, there are commercially available developer phones with JavaFX runtime burned into them coming: HTC Diamond*, LG, Sony Ericsson*)

The new JavaFX 1.2 SDK also brings additional, fully skinnable (via CSS) UI components, full-screen mode, improved data handling (RSS, Atom support, …) and greatly improved performance  – around 40%up for desktop, 20% up for mobile, code size 30% down in an average JavaFX application. The performace improvement is really signinficant – a favorite Bubblemark benchmark test delivered these results on the stage:

  • Microsoft Silverlight – ~90fps
  • Adobe Flex – 58fps
  • JavaFX 1.2 – 124fps

And this is just astonishing: JavaFX is 1.37 times faster than Silverlight and 2.13 times faster than Adobe Flex! I am pretty sure that with the new set of tools for designers, new APIs and components it will be driving even more attention of RIA as well as desktop application developers.

Now, I did spend lots of time and space writing about a single session, but for me as a Java developer it was simply the most interesting talk of the day. Still, I need to add that I attended several other great and interesting sessions today: a talk on OSGi and Java Modularity by Peter Kriens and Harold Carr‘s talk on Metro Web Services Security Usage Scenarios are the two talks definitely worth mentioning.

Now that the official part of today’s conference program is over, I am looking forward to hanging around, talking to people as well as having some beers at tonight’s Jazoon party.


4 thoughts on “Jazoon 2009 – Day 2

  1. Dierk König

    There is only one Elvis (needless to say) and that is the shortcut for the ternary ‘if’ operator as in
    x = foo ?: ‘default’

    whereas ?. is the null-safe dereferencing operator, which is not Elvis (or did he have only one eye?).

    P.S. I’m the one who made the term popular in the Groovy in Action book

  2. Dierk König

    Ah, sorry, misread your post. You were not citing Danny’s error around "?." . Anyway, only "?:" is elvis, not ":?" or the haircut would be the wrong way around 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *