Discussions

News: Lambda in Java 8: A fundamental change in how Java programs are developed

  1. Every dominant programming language on the market today leverages the powerful idea of closures, except for one. The one that's lagging behind? It's Java, and for years it seemed like nothing would get done about it.

    As many as fifteen years ago, when Martin Odersky of Scala and TypeSafe fame, and Phillip Wadler released the experimental "Pizza" project, people have been trying to make closures an essential part of the language. Despite being seen as overly complicated, the Java community seemed to come around to the idea of including closures in the language around 2008. Then those plans were put on hold as Oracle gobbled up Sun Microsystems and Java languished while new releases of the language were repeatedly postponed.

    But things are changing in a big way with Java 8, and the programming community better be ready for it. "This is perhaps the biggest upgrade ever to the Java programming language," says Brian Goetz, Oracle’s Java Language Architect, indicating that the inclusion of closures will change the way Java programs are developed in an even more significant way than the way the inclusion of generics in Java 5 changed the way we code. "Just as generics allowed developers to better abstract over types, the goal of Lambda is to help developers better abstract over behavior."

    Lambda is the name given to the project that binds closures to the Java programming language. And what will Lambda and the inclusion of closures, do? The idea is that programmers will be allowed to treat a chunk of code as though it were a piece of data. A method can be described and characterized in the same manner in which you would declare and use a variable, and that newly characterized method can be passed into a method as though it were indeed an instance or a type. "This may not seem like a big deal, but in reality it is a huge deal," said Goetz. "This will fundamentally change the way we develop Java libraries."

    It has been a long time in the coming, but with the release of Java 8, the Lambda project will finally become a full featured part of the Java specification. A syntax that was originally discarded as too complicated for the typical developer to handle will eventually become a standard artifact to be seen in every modern Java application.

     

    Edited by: JDenman on Oct 1, 2012 4:09 PM
  2. Every dominant programming language on the market today leverages the powerful idea of closures, except for one

     

    that's overstated. how about C? that's pretty dominant and doesn't have closures and probably never will.

    C++ (before C++11 which is not widespread)? Objective-C (before Snow Leopard). Pascal?

    Not having closures is a common theme in C-geneology languages.

  3. C's function pointers are pretty close.  Not "closures" in the category theory sense, but a lot closer than what java can do having to wrap all functions in a class.

  4. C's function pointers are pretty close.  Not "closures" in the category theory sense, but a lot closer than what java can do having to wrap all functions in a class.

    The key point of a closure (not from category theory btw, did you mean monads?) is to "enclose" the (usually lexical) scope of point of definition, including local variables. C functions can only enclose the global lexical scope.

  5. Well, Pascal allows nested procedures and functions which is "closures" as meant in this article. Java anonymous classes also can be nested within a method and they have access to the local variable of the surrounding method, so Java actually has closures already. (With a lot of boilerplate code to type compared to more functional languages).

    And if we use the term closure in its proper (original) sense, then even C and C++ have closures. (Meaning that an identifier used within a scope and not declared in the scope is bound to something declared in an outer scope. e.g. to a global variable or to a function in C)

    Nevertheless, I agree with the article that the Lambda will be a major change to the language and that Java 8 will be more exciting than Java 5 was.

  6. Well, Pascal allows nested procedures and functions which is "closures" as meant in this article. 

    That's true. I forgot about nested functions in pascal.

    And if we use the term closure in its proper (original) sense, then even C and C++ have closures. (Meaning that an identifier used within a scope and not declared in the scope is bound to something declared in an outer scope. e.g. to a global variable or to a function in C)

    Sure, it encloses the global lexical environment, but that's exhibiting a tiny amount of closure-like ability rather than the true definition: to enclose the (usually lexical, but not always: e.g. groovy, early lisp) scope at the point of definition, including local variables.

  7. clang has closures for C[ Go to top ]

    Every dominant programming language on the market today leverages the powerful idea of closures, except for one

     

    that's overstated. how about C? that's pretty dominant and doesn't have closures and probably never will.

    C++ (before C++11 which is not widespread)? Objective-C (before Snow Leopard). Pascal?

    Not having closures is a common theme in C-geneology languages.

     

    clang also allows blocks as C extension. Eventually this extention might standardized, then C will also have closures.

  8. fundamental change could be confusing and bad too. So it depends.

    you have good idea in mind with closures,  but how you provide that to be used by developers is goign to be key. what else is "fundamentally" changing ?

    you dont want it too loose or "depends on runtime". We still like java's design time checks. you need to make sure its as strongly typed as posible.

    Dont make a mess out of it and leave everyone scratching their heads when it comes to  reading someone else's code.  keep it simple...

  9. Better hope they also update the whole java "standard" libraries to take benefits from having lambda in the language. Because if not, it will be like having a nice new hammer without the nails.

  10. Every dominant programming language on the market today leverages the powerful idea of closures, except for one. The one that's lagging behind? It's Java, and for years it seemed like nothing would get done about it.

    As many as fifteen years ago, when Martin Odersky of Scala and TypeSafe fame, and Phillip Wadler released the experimental "Pizza" project, people have been trying to make closures an essential part of the language. Despite being seen as overly complicated, the Java community seemed to come around to the idea of including closures in the language around 2008. Then those plans were put on hold as Oracle gobbled up Sun Microsystems and Java languished while new releases of the language were repeatedly postponed.

    But things are changing in a big way with Java 8, and the programming community better be ready for it. "This is perhaps the biggest upgrade ever to the Java programming language," says Brian Goetz, Oracle’s Java Language Architect, indicating that the inclusion of closures will change the way Java programs are developed in an even more significant way than the way the inclusion of generics in Java 5 changed the way we code. "Just as generics allowed developers to better abstract over types, the goal of Lambda is to help developers better abstract over behavior."

    Lambda is the name given to the project that binds closures to the Java programming language. And what will Lambda and the inclusion of closures, do? The idea is that programmers will be allowed to treat a chunk of code as though it were a piece of data. A method can be described and characterized in the same manner in which you would declare and use a variable, and that newly characterized method can be passed into a method as though it were indeed an instance or a type. "This may not seem like a big deal, but in reality it is a huge deal," said Goetz. "This will fundamentally change the way we develop Java libraries."

    It has been a long time in the coming, but with the release of Java 8, the Lambda project will finally become a full featured part of the Java specification. A syntax that was originally discarded as too complicated for the typical developer to handle will eventually become a standard artifact to be seen in every modern Java application.

     

    Edited by: JDenman on Oct 1, 2012 4:09 PM

    It shows how well you understand this subject. Bookmarked this page, will come back for more.  The Panorama