Skip to main content

Lite closure in JDK7

Posted by forax on November 18, 2009 at 8:58 AM PST

It seems that "lite" closure will be in JDK7.
I really don't care about the surface syntax but I hope that the runtime of such closure will be on top of JSR 292 method handle.


Related Topics >>



There are so many other feature requests that have more consensus and are better for Java than Closures. Why ram this down our throats now?!


I don't know why others want closures but I know why I need them.
Recently, I have ported a Ruby code to Java, don't ask me why it
was first developed in Ruby.
It is a not so simple code that see a graph of node as another graph of node.
For a question of performance this code has to be lazy,
The size of the Java code is 5 times the size of the Ruby code because
conceptually the Ruby code use only 4 kind of closure to do the conversions
but in Java in order to avoid boxing I had to write a lot of interfaces with one method
that takes a char, an int, a long, an Object, etc.. I have more than one hundred of such interfaces.
Ok, the Java code is faster (3x) than the Ruby code, but it was a pain in the ass to write.

JDK7 release is postpone because of the Sun/Oracle deal, so we have more time,
let's try to implement a consensus version of closure.


This one will bring back fun into hacking Java!

BGGA spec has been updated to v06a