I came across Maurice Naftalin’s Lambda FAQ recently – an accessible introduction to lambda expressions in Java for the layman who’d rather not read official proposals. Lambdas will make Java a more terse and a more powerful language. With any luck the SDK libraries will leverage them as will the libraries of Doug Lea and Google. Though it remains to be seen what happens to the readability and maintainability over time of code written with lambdas. But overall I’m very excited about this feature indeed. The only thing I’m less than enthusiastic about is the ‘->’ syntax which is reminiscent of PHP and C++ pointers and these are not pleasant memories. I can’t really think what a good alternative may be; perhaps something colon based – but I really hope they do come up with one.
Oracle have posted the talk that Brian Goetz (one of my favourite technical experts) gave at the JVM Language Summit on 30 July 2012 on implementing lambda expressions in Java. It’s shorter than a classic talk at only 40 mins long. Lambda expressions are due to be released in Java 8 and will be the flagship feature of that release and will also be, without a shadow of a doubt, one of the most important features of all time.
Not only will they make the language more powerful in its expression but with any luck the VM will also be able to introspect and detect latent areas of parallelism and parallelise the execution of those lambda operations. Numerous satellite projects will also leverage the use of lambda expressions in their endeavours – an example being the recent proposal to add GPU support into Java.
Java SE 8 developer preview released with lambda support. The big question now is which editors support Java 8 and lambda syntax? I wasn’t able to find explicit mention of any editors supporting it -I suspect I’ll have to hack around in vim for a while. If you know please comment.
Lately, on the lambda-dev mailing list, dedicated to discussion on closures in jdk7, there’s been an eerie silence. With the feature complete deadline looming in two weeks members of the list have expressed concern at the lack of activity and questioned Oracle’s commitment to the cause. Alex Buckley from Sun has not been forthcoming in his responses which has only served to heighten their concern. Here are a few representative emails the last of which was sent earlier today.
- A reminder of Project Lambda’s scope – Tue Apr 20 13:38:19 PDT 2010
- A reminder of Project Lambda’s scope – Mon Apr 26 11:00:19 PDT 2010
- A reminder of Project Lambda’s scope – Mon Apr 26 11:33:14 PDT 2010
- Close to 0.2 draft? – Mon May 10 09:27:19 PDT 2010
Judging by the lack of activity, the secrecy on the official status and progress of the project, the feature complete deadline looming and the apparent failure to reach consensus on the list despite frenetic discussion on the topic it certainly seems to me that as time goes on it is becoming less and less likely that jdk7 will receive closures in any form whatsoever. If they do not make it into the next version of java it will indeed be a shame as closures were the feature the community was looking forward to the most.
My personal opinion is that in the light of the recent takeover of Sun by Oracle and with the release of JDK7 eagerly awaited by the community (for almost three and a half years I might add) Oracle should, at the very least, offer a degree of transparency on what they are doing and what their plans are for JDK7. As Neal Gafter points out in his most recent post to the list whatever the outcome silence sends the wrong message and I couldn’t agree more.
Update: David Flannagan has published a similar post.
Update: It seems the discussion has once again kicked off with a new proposal by Brian Goetz. However, as Stephen Coulbourne points out, the thought process that Oracle went through to reject other options and come up with this new proposal has not been transparent.
Update: There seems to have been a comment posted on the above linked blog by a member of the Oracle staff saying “There are several resources that are working on closures at Sun/Oracle. We are reviewing schedules for Java 7. As soon as we get done, we will publish those milestones as part of OpenJDK. Java is alive an kicking and so are closures in Java.”. This, if true, is great news.
Update: For those of you coming through from dzone this post is a little out of date. Discussions on closures are in full swing now on the lambda-dev mailing list so there’s less reason for concern.