Here are my impressions from the 18th Java One. Java SE 8 is around the corner, Java EE 7 was just released, and both are a joy to use. NetBeans 7.4 is awesome. And yet, people were strangely blasé at the conference. I still remember how much excitement there was at Java One when Java was in its infancy, and the promises greatly exceeded the reality. (Do you remember Jini? Or the original Java EE?) Nowadays, that excitement is lavished on other technologies whose promises exceed the reality, and Java has grown up.
Apparently people do remember the original Java EE. Not the promise, but the reality. I am amazed how many people still think that Java EE is unbearably cumbersome, and to what lengths they go to avoid it. My favorite presentation of the conference was Adam Bien’s “ Lean and Opinionated Java EE 7 Applications”. He described pretty much what I have found myself doing: Use JAX-RS with stateless beans, don’t use ancient design patterns (DAO, DTO), don’t use Apache Commons when you can use a standard library, focus on the business logic and use the standard EE mechanisms for plumbing. It works for me, but the fact that it works for his customers is a lot more meaningful. He is a funny guy too (for a German at least...) Check him out if you get a chance.
As in the previous five Java Ones, there was much talk about JavaFX. I found it interesting that JavaFX runs so well on the Raspberry Pi, which has the horsepower of an Intel CPU from about 15 years ago. But its GPU is quite good, and JavaFX knows how to work with a GPU much better than Swing did. Oracle has publicly stated that Swing is in maintenance mode, so desktop developers (yes, there still are some left) were hungry for advice on how to transition their apps. Unfortunately, there doesn’t seem to be a silver bullet.
There was a lot of interest in the Java 8 features—all the talks about lambdas were packed. But I sensed more curiosity than excitement, which surprised me a bit since this is easily the biggest Java language change since, well, since Java 1.0. Java 8 is on track for early 2014, with regular snapshots that you can, and should, try out. I have used them without any problems for some time now, as I am writing Java 8 for the Really Impatient (which should be out in a few weeks). I guess we have been waiting for it so long that the excitement has dissipated.
What is my favorite Java 8 feature, other than lambdas and streams? Now, when you keep a
ConcurrentHashMap of counters, you can increment the counter as
map.merge(key, 1, Integer::sum);
If the key isn't present, it is put into the map with a value of 1. Otherwise, it is replaced with 1 + the old value. And yes, it’s threadsafe. (Try doing that in Java 7. The only safe way I know uses
Ok, that’s not fair—that code actually uses lambdas since
(x, y) -> x + y. So, my favorite feature that doesn’t use lambdas is the new Date/Time API. Call
ZonedDateTime nextMeeting = meeting.plus(Period.ofDays(7));
meeting falls on Monday at 10 am, then
nextMeeting is 10 am a week later, even if there was a daylight savings time change. That API is a joy to use and, yes, it too is threadsafe. In this example, the
plus method is immutable.
For me, the most fun presentation was the Raspberry Pi hands-on lab. They didn’t have enough devices, so we had to work with a lab mate. This is something I always do with my students since I figure that four eyes see more than two. It has been over thirty years that I had touched any hardware other than a PC, and I had never done any embedded programming, so those extra eyes were great. Our momentous achievement? We made the green light blink, using Java.