Functional Programming in Java : Write-only Lambdas?
posted 2 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Hi Venkat.
As a Java dinosaur (all the way back to V1 of Java) the syntax for Lambdas is pretty impenetrable at times & reminds me of "write-only" code, back in the days of C.
I'm in the middle of reading a book about a different programming language & I have just seen a paragraph taking a swipe at Java lambdas: "It is quite common nowadays to look at code and come away puzzled. Java lambda code is a good example."
Many of your replies in this forum say that functional programming makes code easier to understand. How do you square that with these comments?
Thanks
Don.
As a Java dinosaur (all the way back to V1 of Java) the syntax for Lambdas is pretty impenetrable at times & reminds me of "write-only" code, back in the days of C.
I'm in the middle of reading a book about a different programming language & I have just seen a paragraph taking a swipe at Java lambdas: "It is quite common nowadays to look at code and come away puzzled. Java lambda code is a good example."
Many of your replies in this forum say that functional programming makes code easier to understand. How do you square that with these comments?
Thanks
Don.
posted 2 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Hi Don,
Programmers can write good code or bad code in any language and in any paradigm. Lambdas are no exception. But, as a team we can do quite a bit to make the code easier to understand and maintainable.
The chapter in the book titled "Functional Programming Idioms" speaks directly to this. Please see the table of contents at https://pragprog.com/titles/vsjava2e/functional-programming-in-java-second-edition
Programmers can write good code or bad code in any language and in any paradigm. Lambdas are no exception. But, as a team we can do quite a bit to make the code easier to understand and maintainable.
The chapter in the book titled "Functional Programming Idioms" speaks directly to this. Please see the table of contents at https://pragprog.com/titles/vsjava2e/functional-programming-in-java-second-edition
posted 2 years ago
-
1 -
-
Number of slices to send:Optional 'thank-you' note:
-
-
The syntax of the λ expression was introduced new in Java8 and had to be sufficiently different from existing syntax that there would be no confusion with old code. I had to get up to date and learn new syntax when it came in, and now they are usually clear as crystal to me. Usually!
posted 2 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Don,
The lambda syntax is different from "normal" Java code, but I don't think it's confusing. If you look at this description from W3Schools I think you'll agree that it's not that hard to understand...
Hoping this helps,
Burk
The lambda syntax is different from "normal" Java code, but I don't think it's confusing. If you look at this description from W3Schools I think you'll agree that it's not that hard to understand...
Hoping this helps,
Burk
SCJP, SCJD, SCEA 5
Voted JavaOne Rock Star in 2010 and recognized as a Java Champion in 2020.
"Any sufficiently analyzed magic is indistinguishable from science!" Agatha Heterodyne (Girl Genius)
posted 10 months ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Lambda Expressions, also known as lambda functions, are anonymous functions that can be passed around and called like regular Java methods. They're a part of Java 8 and onwards, allowing us to write more concise and readable code.
Here's a simple Lambda Expression syntax: params -> body
Where:
params: are the parameters for the lambda expression.
body: is the code block that Lambda performs.
Refer: https://reloadbasics.com/java/Working_with_Lambda_Expressions for more info
Here's a simple Lambda Expression syntax: params -> body
Where:
params: are the parameters for the lambda expression.
body: is the code block that Lambda performs.
Refer: https://reloadbasics.com/java/Working_with_Lambda_Expressions for more info
Campbell Ritchie
Marshal
Posts: 81605
593
posted 10 months ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Welcome to the Ranch 

No. a λ function is different from a λ expression. A λ function is a mathematical generalisation of a particular kind of function and a λ expression is a Java® idiom for creating an object. If you look at the old anonymous local class idiom, you will find that you can derive a λ expression from an anonymous class created from a functional interface.Kumar S wrote:Lambda Expressions, also known as lambda functions . . .
I hope you didn't write that tutorial, because it is just about the worst tutorial I have ever seen. The code in it is all incorrect.. . . https://reloadbasics.com/ . . .
| So it takes a day for light to pass through this glass? So this was yesterday's tiny ad? The new gardening playing cards kickstarter is now live! https://www.kickstarter.com/projects/paulwheaton/garden-cards |






