4 ms·
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
by ninjakeyboard 12y ago
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.
- iwince 12y agoThey are a step backward. They try to make a complicated thing look simple. That is always a mistake.
- mekaj 12y agoIt'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.
- phamilton 12y agoI 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.