My favorite enterprise language seems to be running out of good ideas to implement.
From this post detailing the upcoming language features of Java 7, here is the list of completed features to date:
- Language support for collections
- Automatic Resource Management
- Improved Type Inference for Generic Instance Creation (the “diamond” operator)
- Underscores in numeric literals
- Strings in switch
- Binary literals
- Simplified Varargs Method Invocation
Now, keep in mind, usually the most critical, important, or difficult features are implemented first. At least if you’re trying to get something out that is meaningful. But seriously, this is what Sun thought was the most important?
Without repeating the details of my Scottish friend who went to great lengths describing each feature, let’s examine the sum of them:
Features 1, 3, 4 and 6 are nothing more than just syntactic sugar…lessening the burden of cumbersome code, but really adding little real value to the language. I have never, ever in my entire career walked around in the middle of a software project saying to myself…
“Boy, the ONE thing missing from my code is changing this:
Map<String, List<String>> anagrams = new HashMap<String, List<String>>()
Map<String, List<String>> anagrams = new HashMap<>();
OK, so that leaves three features with hopefully some potential value. One of them has to do with varargs–a solution in search of a problem. Kind of the way I feel about Regular Expressions, because now I have two problems: the original one and understanding/debugging/maintaining varargs. How many times in your career have you actually found varargs useful? Personally, I’ve known about it for 17 years and I can count on one hand the number of times I used it (Two). And I probably could have done it differently on one of those occasions. I wouldn’t exactly call this a major win here.
So we’re down to two. Strings in Switch and Automatic Resource Management.
Strings-in-switches is a nice-to-have but certainly not mission critical. I stopped avoiding switch statements about the time when enums came out in Java 5. Before enums, I felt dirty with switch statements–like I was hiding magic numbers in my code. I celebrated the return of my cherished user-defined types and happily upgraded to Java5 for that feature alone. But strings-in-switches don’t feel like a comparable major gain here. Maybe this will convince the Visual Basic crowd to finally migrate over to Java. Don’t think I’m holding my breath on that one.
But for the last one, I’ll give a huge, unabashed thumbs up to Automatic Resource Management. The Number One Problem all Java developers faced since Duke first appeared was resource leaks. The Garbage Collector gave us respite from the horrors of memory management, but resources still sat in the dark corners of the application, quietly waiting to slash our ankles as we forgot about them. Files. Databases. JMS connections. Sockets. Oh, and that’s just scratching the surface. So hip-hip-hurrah for resource management! (I will throw out one small snipe at Sun while I’m on the subject: Why did you wait so long for this one?)
So if this is the best and most important feature set available for Java7, I’m going say that Java has definitely jumped the shark.