Wednesday Jun 24, 2009

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
            break;
        case "green" :
            // do green stuff
            break;
        case "blue" :
            // do blue stuff
            break;
        default:
            // do default stuff
            break;
    }
  

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) {
        Integer countVal = hitCounts.get(pageName) ?: 0; // if there are no hit counts stored in the map, use 0 as a current count value
        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.

Cheers!

About

potociar

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today