Sunday, November 20, 2011

Devoxx 2011

I attended the Devoxx 2011 conference in Antwerp, Belgium (thank you RSA Security).
This is the second large conference I've attended, the first being Java ONE in 2007, and I had a great time.

Stephan Janssenn and the Devoxx team did an excellent job organizing the conference.
The conference was packed with over 3,500 participants, 95% men, situated in Metropolis Antwerp Business Center.
The lecture halls were actually cinema theatres. Even though I haven't seen a movie in them (I missed the "Tintin 3D" feature film) they are hands-down the best cinema theatres I've been to, with more than enough leg room, extremely comfortable seats and arm rests which you don't need to fight over :)
Between lectures the screens showed the twitter wall, which was a brilliant idea I liked very much.

Every participant got a wrist band, very similar to the one I got a few months ago from the maternity ward when my son was born.
The thing is, it has to remain on your wrist until the conference is over. I can see why some people found this annoying but it actually worked in my favor, while sitting in the lobby of the hotel waiting for a taxi to take me to the conference the guy that sat next to me also wore the wristband so we ended up talking and sharing the ride.

Day 1: The Java SE keynote by Henrik Stahl was good. There was no big announcement, but I liked the message "Java will always be there for you".
I got a little bored in Cameron Purdy's Java EE keynote, where he promoted Weblogic and Oracle servers and left before it ended.
The "Play 2.0" talk was very good. I was impressed with the creativeness of Play 1.0 when I started using it, but these guys don't rest. They added innovative features to Play 2.0 continuing to make web development easier and faster.
"7 reasons to love JBoss AS 7" sounded promising but lacked technical details. It felt more like a marketing pitch. But it sounds promising and I'll need to check it out.
I then moved to the "JRuby enhancing Java developers' lives" talk, but it started off showing how to write web applications in Ruby, so I left and joined the "PhoneGap" talk, which was very amusing. I even managed to pick up a thing or two about mobile development, which is something I haven't tried (yet).
Next was "NoSQL for Java developers" which showed how a restaurant directory application would look like in an RDBMS (MySQL), a Key-Value store (Redis), a document store (mongoDB) and a multicolumn DB (Cassandra).
I think it's wrong to demonstrate all of them using the same use case. Each DB was built to solve a specific set of problems. Assuming the goal of the lecture was to show how non-relational DBs defer from relational DBs, then to show the strengths of every DB you need a different use case. E.g. show how your web application sessions would work with a KV store as opposed to RDBMS, how document stores have flexible schemas as opposed to rigid schemas in an RDBMS, and how queries performance differs as you scale out.
My day ended with an excellent talk from Brian Goetz about "Language/Library co-evolution in Java SE 8" which focused on Lambda and Closures, and how the existing JDK libraries might be enhanced to use these new features.

Day 2: The keynote from Tim Bray convinced me I should write mobile apps. I'm pretty sure I'm not gonna save the world, but I'm sure to it will be fun.
In the "Introducing Akka" talk I understood the concept of "Actors" and it sure sounds like a good tool to have in your developer toolbox.
"JMS 2.0" showed that there's not much to change in the JMS spec. If the spec wasn't 10 years old I would name the new spec version 1.2 :)
I then went to "Why we shouldn't target women", which about the state of female developers in the IT world. I was surprised to hear that in France and the UK only 15% of CS graduates are women. It was an interesting discussion without any conclusions.
"Java Posse live" was a comic relief. I got a beer and sat on the stairs to watch the show. I'm not sure this Posse podcast will provide much value to the listeners :)
"Having fun with Java and Home Automation" was a peek at the future. You'll be able to control and follow your house on twitter.
I ended the day with the "Code Generation" talk which got me thinking about the need for code generation in enterprise projects in the annotations era, see what Play! does in this area. I'm not sure it's very useful these days. I did learn a bunch of new stuff from the Xtext, Xtend and Spring Roo code generation demos.

Day 3: The final day began with a technical discussion panel which was interesting mostly because of the cynical remarks from Oracle and Google people.
I decided I had to go to one HTML5 talk so I entered "HTML5 Game Development" which was very good. Animation always make me feel I should brush up my Mathematics.
The last talk was about "Shazam", which is an app that identifies songs by hearing them. Roy van Rijn did a fantastic job explaining how he built a similar application in Java, including a good explanation about Fourier Transformation using a yellow stick. His talk ended with a lively discussion about software patents and violation after getting intimidating emails from Landmark (the company holding the Shazam patents).

Notes for next year:
  • Don't stay at Novotel Antwerp. It has no public transportation and no entertainment in its vicinity.
  • Set aside more time to see Antwerp. I have no idea what the city looks like.
  • Get a larger suitcase. My small trolley almost didn't have room for all the marketing items handed out at the booths.
See you again next year!

Sunday, February 6, 2011

Autoboxing puzzler

While performing code review I came across the following code (simplified for this post)

private void box(Long l) {
 if (l.equals(1)) {
 else {
  System.out.println("not eq");

What will be printed when we call box(new Long(1))?
Can you spot the bug?

The condition l.equals(1) will always evaluate to false.

This happens due to the autoboxing specification and the implementation of the Long.equals() method.
According to the specification if the primitive value (1 in this case) is an int it is converted to a reference of class Integer.
The Long.equals() method starts with type comparison using the instanceof operator, which returns false for an instance of type Integer.

A possible solution is to compare the value to a reference of class Long value using if (l.equals(1L)), which boxes the value 1L to a Long.