One of the most discussed (and most controversial) topics in the last years concerning the future of Java was the introduction of Closures. After 2008′s Devoxx Closures were off the Java7 release. One year later at the same event Mark Reinhold revoked it and announced that Closures will be in Java7 (and hence delaying Java 7 for a few months).
For days ago, Reinhold published a straw-man proposal of how closures (or more formal: lambda expressions) could look like in Java. I’m still not sure whether I’m happy about closures in Java or not. On the one hand it definitely helps to reduce the number of lines of code since it drops redundant information (e.g. the decleration of a Runnable).
Thread th = new Thread(new Runnable() {
public void run() {
doSomeStuff();
doMoreStuff();
}
});
Thread th = new Thread(#(){ doSomeStuff(); doMoreStuff(); } )
On the other hand it increases the complexity of the JVM itself and makes maintenance a bit harder. This will affect only few developers but it’s another stop to the grave of Java (death by non-maintainability).
I think time will tell how Closures will affect the Java world and if it’s a good idea to include it or not.
Recent Comments