Java Closures Death Match
With the recent surge in Java closures blogs, I thought I would do a roundup on some recent hot topics. Probably the most important development is that we now have prototypes for the three major closures proposals. That means it's time for the steel cage death match!
Ok, I guess that's not really necessary. But we do have the tools now to do a comparison on syntax and functionality of these proposals:
- BGGA (spec) - Neal Gafter is driving the most thorough proposal
- FCM (spec) - Stephen Colebourne and Stefan Schulz have a method-oriented approach
- CICE (spec) - Josh Bloch is championing a simpler approach to simplifying anonymous inner class syntax
java.net has been running a poll on closures and the results are kind of interesting. At the moment, BGGA is in the lead, but neck and neck with NO closures. FCM is making a respectable showing (given it's lower profile) and CICE has only a tiny percentage. I suspect this poll probably isn't too useful since the vast majority of those voting have not taken an in-depth look at the proposals and really understood the details and differences. Peter Ahé (former tech lead for javac), requested a boycott of the poll in principle.
Another area of focus lately has been on the closure syntax, which of course is something that will look foreign to any Java developer unfamiliar with closures. Here are some recent syntax articles:
- Brian Gilstrap: Alternate Syntax for Java Closures
- Weiqi Gao: Dreaming Up Syntax For Function Types For BGGA Closures
- Alex Winston: Closure Syntax
- WarpedJavaGuy: Pointer Syntax for Java Closures
- Weiqi Gao: It Looks Like I’m Not Alone
- WarpedJavaGuy: Closure Syntax Wars
- Cedric Champeau: Java BGGA closures proposal and the Groovy syntax
I can't say I'm too excited about the pointer syntax idea. I find FCM's syntax to be a little nicer in general although I don't like the placement and notation of return types. I initially disliked BGGA's syntax, but I've seen enough of it now that it doesn't bother me. I think the final blog there is an interesting one and it would be convenient to use the same syntax in Groovy and Java.
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)