Could closures be generics all over again?
I was listening to the Java Posse this morning, and their choice of topics was interesting: they started with last week's white-hot back-and-forth over the idea of adding closures to the Java language in JDK 7, and then got into the much-linked weblog entry Java 5 Language changes were a bad idea.
Near the end of the latter discussion, they talked about what they thought were three typical stages of adoption of new language features, which go something like this:
- This is great!
- No, wait, this sucks!
- You know, this is pretty good after all.
Accurate? Maybe. I'm not sure if we had people changing their mind on generics and autoboxing so much as we had a lot of people not really paying attention to them until they were part of the language and everyone suddenly had to care. After all, even if you don't use generics, you might be responsible for someone else's code that does. And from this, we saw the backlash against some of these JDK 5 features, not just now in Shai's weblog, but last year in a number of places (for example, see last October 19th's Daily Editor's Blog Broken Hearts Are For...).
Yet the Posse say that by embracing generics, they've turned up a number of bugs that they might not have found otherwise. So they've moved on to the third stage of this progression.
Now, they didn't make this comparison explicit, but it's not hard at all to imagine being at step one of this process again, this time with closures. A lot of people (myself included) are excited about the potential to eliminate some ugly inner-class anti-patterns with the use of closures. The Posse also wondered aloud if the implicit state-save of a closure would then lead to support for continuations, which would be remarkable. But there are some already expressing a concern with the syntax of the Java closure proposal, and others asking if this is truly worth adding to the language, with the requisite increase in complexity of adding another programming metaphor.
Will we get closures in JDK 7? Will I be linking to bloggers who say that closures suck, only to then have everyone agree later that they're actually really useful and more than syntactic sugar?
The Java Today section kicks off with a new resource to foster understanding and discussion of the Java closures proposal. The wiki page Closures Syntax in Java 7 collects resources from around the web related to the new proposal to bring closures to the Java language in JDK 7. The page links to the original PDF proposal, blogs, and running discussions on the proposal, and also hosts its own "Discussion on Syntax" section for further debate over the specifics of the proposal.
The ninety-first issue of the JavaTools Community Newsletter is online, collecting tool-related news from around the web, welcoming two new projects to the community (Enuke and Source Code Mania), and featuring a tip of the hat to the Java Posse podcast.
Ed Burnette points out a surprising combination of projects in EoS - Eclipse on Swing: "In what has to be one of the most cleverly named projects of all time, EoS (named after Eos, the Greek goddess of the dawn) promises to bring Eclipse to Sun's Swing platform. EoS is the result of a collaboration between Dieter Krachtus and SWTSwing developer Chris Deckers. A download is available, but it's currently more a proof of concept than a usable system."
Back to the closures discussion Tom