Re:What's Stopping Me Using Java8 Lambdas – Try Debugging Them
by ninjakeyboard on Sunday January 18, 2015 @10:23AM
(#8907711)
This is a weak argument. It's like saying we should avoid concurrency because it's harder to debug. Lambdas are a step forward and nothing short than that. I've been working with Java8 professionally for about 8 months and have trained about 5 teams on the new tooling. I've never seen anyone raise debugging their code as a reason to use an anonymous object instead of a lambda.
[ Parent
| on HN ]
Re:What's Stopping Me Using Java8 Lambdas – Try Debugging Them
by iwince on Sunday January 18, 2015 @11:28AM
(#8907873)
They are a step backward. They try to make a complicated thing look simple. That is always a mistake.
Re:What's Stopping Me Using Java8 Lambdas – Try Debugging Them
by phamilton on Sunday January 18, 2015 @12:22PM
(#8908043)
I think that is true in the case of forEach loops. However there are plenty of other situations in which the lack of lambdas has made something simple far more complicated. One example is the Strategy Pattern. With lambdas it's a fairly simple thing. Without lambdas there are a bunch of hoops you have to jump through.
Additionally, I feel that lambdas enable constructs that are much clearer and easier to reason about. Consider the case where you want to transform ever element in a list and produce a new list. Without the map function (which depends on lambdas) the logic wouldn't be that bad, you would create an empty list and append each element ad they are processed in a for loop. However, the intent of your code is less clear. Add in filtering and the intention of the code in your for loop ends up quite a bit harder to understand compared to a fairly straightforward select and map.
Re:What's Stopping Me Using Java8 Lambdas – Try Debugging Them
by mekaj on Sunday January 18, 2015 @11:46AM
(#8907922)
It's not always a mistake. Abstraction has a purpose. The key is using abstractions that are helpful.
Some people find the concision of lambdas helpful, so it's not necessarily a mistake.