Friday, April 27, 2007

Java Closures

Here we go again with language syntax changes...but this time is it different?

Brian Goetz recently posted an article on IBM DeveloperWorks about closures in Java. It is a well-written description of both the theory behind closures and the two proposals that are currently being considered for including them in Java.

I applaud the article, but as for the issue, I don't really like either proposal very much. BGGA is just more of the increasing complexity of syntax that, IMNSHO, is going to kill Java. On the other hand CICE does not appear to go far enough in simplifying the syntax. It seems that what is keeping the syntax so ugly is the damn static typing, having to declare the types of all your variables; if we could get away from that we'd have lots simpler syntax options (and we'd not be in Java anymore :-)

I guess I'll root for CICE, since it is fairly obvious that one of thee two is going to be The One. However, I was delighted to see this at the end of the article, since it is precisely what I have been harping on for so long in relation to the Parameterized Types decision:

"The issue being debated is not whether closures are a good idea -- because they clearly are -- but whether the benefits of retrofitting the Java language with closures are worth the costs."

That quote notwithstanding, does anyone really believe this proposal won't be railroaded through now that the camel's nose is under the tent?

No comments: