November 19, 2009

Closures for Java 7

Yes it's true! Java 7 will indeed have closures. I was enthusiastically following the Java closures war in 2007, and subsequently had lost hope that Java will ever have closures. But now it seems like the heads at SUN have changed their minds after all. This was announced by Mark Reinhold at devoxx.

Let's hope they do it right. Which of the various closure proposals will be used? Apparently it will be a mix of them all. Syntax-wise it resembles the simplistic FCM proposal, semantic-wise it partly uses the BGGA approach: seems like assignments to captured non-final variables could be in, but non-local transfers will be out (using break or continue within closure code will yield a compile-time error). Sadly this also strikes out BGGA's innovative control-statement-invocation syntax. Anyway, they have changed their decision once so there is still hope for more BGGA support.

Some quick links pointing to various sources of this news:

Updates:

Catched a comment from Neal Gafter on Ted Newards blog:
I had been discussing this spec [BGGA 0.6a] with Gosling, but I have had no contact with Reinhold.
And another one on Cay Horstmans blog:
the 0.6a specification is NOT BGGA, nor is it intended to document Mark Reinhold's plans for JDK7. [...] it resulted from a discussion with the other authors of the BGGA spec culminating in this document a couple of weeks ago [...] I was attending PDC09 when I read a tweet about closures and put up the link. I think the timing and similarity to Mark Reinhold's announcement are either coincidental or Gosling has passed it on to him. [...] Note that this spec allows access to non-final local variables from the enclosing scope, which rumors suggest Reinhold has ruled out.
It's a shame Neal does not blog about closures himself anymore.

October 6, 2009

Memories of the (Next Generation) Future

By chance I recently came upon Memories of the Future, a book written by Wil Wheaton, actor of Wesley Crusher in the tv series Star Trek The Next Generation. I am happy not to have missed on this one before it is released in a week or so, which is why I am posting about it now, contributing to the publicity of the book (and because Wil ordered me to do so in his podcast).

Wil releases podcasts with excerpts of his book on a weekly basis. The book is a humorous recap of the first season of the series, from a Wheaton/Crusher point of view. Best part so far for me is how Wil manages to recapitulate the episodes as if Wesley - a mere 14 year old boy - had been the hero of the show, while at the same time knowing that this character was hated by so many fans, and he as an actor was so bloody inexperienced.

I never hated Wesley though. As I had been at similar age, when I first saw the series, I could perfectly identify with him as a character. I am totally going to enjoy the book. If you are not going to buy it, at least go tell your friends about it.