You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-dev@hadoop.apache.org by Jim Brennan <ja...@verizonmedia.com.INVALID> on 2021/04/29 14:03:34 UTC

Re: [E] Re: Java 8 Lambdas

I just think that we should be cognizant of changes (particularly bug
fixes), that will need to be ported to branch-2.10.  Since it is still on
Java7, anytime you use a lambda in code on trunk, we need to change it for
branch-2.10.   While not difficult, this is extra work and it increases the
differences between branches, which can also cause more conflicts when
porting bug fixes back.


On Wed, Apr 28, 2021 at 9:28 PM Ahmed Hussein <a...@ahussein.me> wrote:

> Thanks Eric for raising this issue!
>
> The debate about lambda is very complicated and won't be resolved any time
> soon.
>
>  I don't personally know a lot about the
> > performance of lambdas and welcome arguments on behalf of why lambdas
>
> No one probably knows :)
> - Lambda performance would depend on the JVM implementation. This changes
> between
> releases.
> - Java8+ features forces lambda. For example,
> ConcurrentHashMap.computeIfAbsent()
>
> I believe that we can transform this discussion into specific action items
> for future commits:
> For instance, a couple of those specifications would be:
> - No refactor just for the sake of using Lambda, unless there is a strong
> technical justification.
> - Usage of lambda in Unit-tests should be fine. If lambda makes the test
> more readable, and
>   allows passing method references, then this should make the unit-tests.
> - We put sample code in the "how-to-contribute" to elaborate "capturing Vs
> non-capturing"
>   lambda expressions and the implications of each type on the performance.
> - Without getting into much detail, IMHO, streams should be committed into
> the code
>   in exceptional cases. The possibility of executing code in parallel makes
> debugging
>   a nightmare. i.e., Usage of ForEach needs to be justified, what does it
> bring to the table?
>
> On Tue, Apr 27, 2021 at 3:07 PM Eric Badger
> <eb...@verizonmedia.com.invalid> wrote:
>
> > Hello all,
> >
> > I'd like to gauge the community on the usage of lambdas within Hadoop
> code.
> > I've been reviewing a lot of patches recently that either add or modify
> > lambdas and I'm beginning to think that sometimes we, as a community, are
> > writing lambdas because we can rather than because we should. To me, it
> > seems that lambdas often decrease the readability of the code, making it
> > more difficult to understand. I don't personally know a lot about the
> > performance of lambdas and welcome arguments on behalf of why lambdas
> > should be used. An additional argument is that lambdas aren't available
> in
> > Java 7, and branch-2.10 currently supports Java 7. So any code going back
> > to branch-2.10 has to be redone upon backporting. Anyway, my main point
> > here is to encourage us to rethink whether we should be using lambdas in
> > any given circumstance just because we can.
> >
> > Eric
> >
> > p.s. I'm also happy to accept this as my personal "old man yells at
> cloud"
> > issue if everyone else thinks lambdas are the greatest
> >
>
>
> --
> Best Regards,
>
> *Ahmed Hussein, PhD*
>