Does anybody know, if closures will be in Java 7?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
Groovy is the best Java alternative I've seen that includes features of dynamic languages including closures, run-time class extension, etc. While Ruby has a slight design advantage imho, I'd have to say the fact that Groovy compiles into Java byte-code and interacts with Java without ANY interface code is a huge plus that can't be ignored.
http://groovy.codehaus.org
Closure won't definitively be present in Java 7, but if you are looking for a lighter solution to have closure in java right now check out how they have been implemented in the lambdaj library:
http://code.google.com/p/lambdaj/wiki/Closures
It is unknown until the Java SE 7 JSR is created (presumably by Danny Coward) and an expert group is formed and the contents selected.
My Java 7 page is a good collection of links about Java 7 in general and has links to all of the closures proposals and blog entries:
http://tech.puredanger.com/java7#closures
And I maintain a Java 7 link blog where you can find links on closures and other stuff at:
http://java7.tumblr.com
And you might find my Java 7 Predictions blog post to be interesting as well if you want my opinions: http://tech.puredanger.com/2008/08/02/java7-prediction-update/
UPDATE: Mark Reinhold stated at Devoxx in Dec. 08 that closures will NOT be included in Java 7 due to a lack of consensus on how to implement.
Apparently Closures will not be in Java 7. See this and this.
There are currently several competing proposals, BGGA, CICE, among others. Unfortunately, a heated debate remains over the best approach. As a result it is unlikely at this point that closures will make it into Java 7, due to the conservative nature of the acceptance process.
The key problem here is that it can be very difficult to add features to a pre-existing language, without inadvertently introducing significant complexity. This was the experience with Generics in Java 1.5, and many are concerned that it would be compounded with the introduction of closures.
My advice is that if you really want to have access to modern language features like closures, but wish to stay within the Java ecosysteym, you should take a look at Scala.
At Devoxx 2008, Mark Reinhold made it clear that closures will not be included in Java 7.
Wait! Closures will be included in Java 7. Mark Reinhold announced this reversal at Devoxx 2009.
Belay that! Closures (lambda expressions) have been deferred until Java 8. Follow Project Lambda (JSR 335) for more information.