Skip to main content

JaveOne 2007, Java Puzzlers Points Out Problems with Kitchen Sink

Posted by johnm on May 9, 2007 at 10:14 AM PDT

Josh Bloch and Neal Gafter have been doing their wonderful Java Puzzlers shtick at JavaOne for the last 4 years. This year, Bill Pugh has stepped in for Neal to keep the puzzlers puzzling.

The puzzles point out all sorts of interesting and exasperating gotchas in the Java language and libraries that linger for ages waiting to humble us all.

This year's set of puzzles include a slew of problems that come as a direct result of the addition of auto-boxing/-unboxing of primitives to/from their object wrapper types (int and Integer, for example). Maybe it's just me but I seem to recall a lot of us who said how bad the consequences would be of adding auto-boxing to Java and yet here they are causing exactly the worst kinds of insidiously non-obvious problems.

The moral of these puzzles isn't merely "be careful of using wrapper types with the ternary operator", but that auto-boxing is evil and should have never been added to the language in the first place.

Of course, it goes without saying that this is just one example of how new "features" added to a mature language are very dangerous. One of the big, currently brewing brouhahas is over the proposed addition of closures to Java. Perhaps folks might want to pause their rampant fervor for a bit and actually look at the history of these attempts and realize just how costly these changes really are. Especially when there are plenty of alternatives like using other languages which have their pet features which target the underlying JVM.

As Josh so eloquently put, "APIs, like diamonds, are forever."

Related Topics >>