How will closures in Java impact the Java Community?
Posted
by
Ryan Delucchi
on Programmers
See other posts from Programmers
or by Ryan Delucchi
Published on 2011-04-13T18:46:10Z
Indexed on
2012/09/29
21:49 UTC
Read the original article
Hit count: 230
It is one of the most talked about features planned for Java: Closures. Many of us have been longing for them. Some of us (including I) have grown a bit impatient and have turned to scripting languages to fill the void.
But, once closures have finally arrived to Java: how will they effect the Java Community? Will the advancement of VM-targetted scripting languages slow to a crawl, stay the same, or acclerate? Will people flock to the new closure syntax, thus turning Java code-bases all-around into more functionally structured implementations? Will we only see closures sprinkled in Java throughout? What will be the effect on tool/IDE support? How about performance? And finally, what will it mean for Java's continued adoption, as a language, compared with other languages that are rising in popularity?
To provide an example of one of the latest proposed Java Closure syntax specs:
public interface StringOperation {
String invoke(String s);
}
// ...
(new StringOperation() {
public invoke(String s) {
new StringBuilder(s).reverse().toString();
}
}).invoke("abcd");
would become ...
String reversed = {
String s =>
new StringBuilder(s).reverse().toString()
}.invoke("abcd");
[source: http://tronicek.blogspot.com/2007/12/closures-closure-is-form-of-anonymous_28.html]
© Programmers or respective owner