Back from JaZOOn, Fourth and Last Day

In the morning, Neal Gafter gave some insight into “Adding Closures to the Java Programming Language“. You remember anonymous classes? Well, closures are similar but solve all the problems associated with it: You can access and modify variables from the surrounding method, for example. You can use closures to replace all the listeners in Swing. Look at this code:

 InputStream is = createStream();
 try {
    doSomething(is);
 } finally {
    try { is.close(); }
    catch (IOException e) {
       log.warn("Error closing", e);
    }
 }

What do we have here? The actual information is the “doSomething()”. That’s where the interesting stuff happens. Everything else is boiler plate code. Now imagine you must change the logging. You have copied this code a thousand times. The stream has often a different name or it’s a Reader. You can bet that you’ll forget to make the change in at least one place. Okay, it’s just logging, but how often have you seen this pattern repeated? A piece of code where the meat is embedded deeply into some other Java code and the whole thing is duplicated with cut&paste all over the place. That’s what closures are for:

 with (InputStream is : createStream()) {
    doSomething(is);
 }

with() is a method which takes two arguments: An InputStream and a Closure. The code for with() looks somewhat like this:

 void with(InputStream is, {InputStream => void} block) {
     try {
         block.invoke(is);
     } finally {
         try { is.close(); }
         catch (IOException e) { log.warn("Error closing", e); }
     }
 }

As you can see, the code wrapping the closure is now in one place. The same pattern can be used when reading objects from a database (in this case, with() could handle the opening and closing of connections, statements and ResultSet’s). Neal showed examples how to use this in listeners or how to have a loop in the with() method. In this case, “break” in the closure can exit the loop (if you have read enough objects from the database or enough files from the file).

Great stuff. Late but great.

After him, Danny Coward showed how Java will evolve into Java SE 7 and Java EE 7. Not many surprises here. Sun aims for a 18 to 24 month release cycle. That is should give the expert groups enough time to come up with great and stable features. We’ll see about that. I would prefer if they came up with useful features that made developing software easier. For example, annotations in Java 5 could have been a great feature but they can’t modify the code. Makes sense from a compiler point of view but castrates the feature. And don’t get me started with generics. I couldn’t even name a feature of Java 6 that I had seen and that I feel helps me in my daily work.

Enough of that. Where does the big world spin to? Henry Story showed Web 3.0 (and Web 2.7 a.k.a Freebase). The “Semantic Web”. Every information annotated with an URI to tell what it is and how it is related to another information. The whole world seen in 3-tuples. Unfortunately, tools aren’t there, yet. If you don’t want to use VI and cwm, there is not much to chose from. You can try Protégé, Swoop or a commercial product TopBraid Composer. All this looks very promising, especially in relation to JCR/Apache Jackrabbit. Jackrabbit allows to store structured and unstructured data and manage it (search, modify, import, export). This is one step above relational databases which offer only very limited capabilities when it comes to data which is only partly structured or not structured at all (like texts, images and videos). If you’re lucky, you can store this types of data but searching it? Forget it.

The semantic web (SW) looks at the problem from the other side: It allows to annotate data with types, so you can know (or rather, your programs can know) if two “things” are the same, similar or related. Example: You are a person. You have a name. In the SW world, “you” is an object or entity of type “Person”. Your name is a value of type “Person:name”. If you know someone, you can attach the relation “knows” to the entity “you” and then refer to other person objects. Since the code walking this graph knows that it’s traversing persons, it knows that there are names somewhere so it can display them on the screen when you list all the people that you know, etc. For more information, see Henry Story’s BabelFish blog. Maybe start here.

He explained many more details and answered questions in the long Q&A session after his talk. I wished there had been more of these. Many talks raised interests but 5 minutes were never enough to ask any complicated questions.

The talk “JCR, the Content Repository API for Java” wasn’t very interesting for me because it mainly focused on the API. Peeter Piegaze showed different node types and typical Java code. Therefore, I didn’t attend “Content Management with Apache Jackrabbit” but “Development of a 3D Multiplayer Racing Game“. I had hoped for some insight into the problems Evangelos Pournaras had ran while developing the game or details of the physical simulation. Instead, he listed the features and showed the UML diagram of the game. I was very disappointed.

Afterwards, the conference closed with the Jazzon Jam. Over the several days, the moderator had told us about something called “Lighning Talks”. People were supposed to walk on stage, get the mike for two minutes and talk about whatever they want. I was a bit suspicious of the concept but it works. Speakers don’t have time to dally around (setting up the laptop counts against the two minutes!) and get their point over quickly. A nice way to close a conference.

All in all, a positive experience. If possible, I’ll attend the Jazoon’08.

2 Responses to Back from JaZOOn, Fourth and Last Day

  1. Neal Gafter says:

    The code should be

    with (InputStream is : createStream()) {
    doSomething(is);
    }

  2. Aaron Digulla says:

    Thanks, fixed 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s