During a Java integration project I did last year I discovered lambdaj and was immediately convinced by its ability to let me produce more readable code faster. I remember reading about lambda expressions coming to 1.8 around that time as well and thinking that I had found a plugin that already brought me all that functionality.
Now I'm revisiting lambda expressions and see that I may have been mistaken on lambdaj's purpose and scope. The way I see it now, lambdaj doesn't really offer lambda expressions but is rather a domain specific language designed to replace repetitive loops on collections. Its DSL syntax was made to look similar to anonymous functions and provides some of the same functionality such as closures and curried functions, but in the end it's limited by the JLS.
I'm now wondering what 1.8's lambda expressions can bring to a Java project that lambdaj can't. Is it just a matter of increased performance with native support for anonymous functions? Will expressions similar to lambdaj's collection manipulation functions be present in 1.8? Or are the lambda expressions in 1.8 meant for me to create my own anonymous functions. In that case, should a specific version of lambdaj be made for 1.8 that recreates the function library using real anonymous functions?
Lambda expression is an anonymous method (method without a name) that has used to provide the inline implementation of a method defined by the functional interface while a method reference is similar to a lambda expression that refers a method without executing it.
How to replace lambda expression with method reference in Java 8. If you are using a lambda expression as an anonymous function but not doing anything with the argument passed, you can replace lambda expression with method reference.
Anonymous class is an inner class without a name, which means that we can declare and instantiate class at the same time. A lambda expression is a short form for writing an anonymous class. By using a lambda expression, we can declare methods without any name.
Cons on lambda functions:Lambda functions can have only one expression. Lambda functions cannot have a docstring. Many times lambda functions make code difficult to read. For example, see the blocks of code given below.
Forget lambdaj and start using Java 8 lambda expression asap!
Mario Fusco - lambdaj creator
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With