Re: Report: Will Java 8′s Lambda Change The Face of The World?
François Sarradin
fsarradin at xebia.fr
Thu Nov 8 05:06:44 PST 2012
2012/11/7 Olexandr Demura <oleksander.demura at gmail.com>:
> On the "The new syntax is nice, but not for everyone" part.
> 1. `map` and `reduce` can be combined into one `fold`, but your code example
> shows it would be clumsier.
>
> Streams.stream(myCollection)
> .map(product -> product.getUnitPrice() * product.getQuantity())
> .reduce(0.0, (subTotal, price) -> subTotal + price)
>
> vs
>
> products.stream().fold(
> () -> 0.0,
> (subTotal, product) -> subTotal + product.getUnitPrice() *
> product.getQuantity(),
> (subTotal1, subTotal2) -> subTotal1 + subTotal2 /* not used if
> sequential */);
Before fold, there was a mapReduce method, with almost the same
signature. I have presented this method. But it has not convinced the
audience. That fact is that the map part and the reduce are separated.
The audience has not understood why they are separated.
> 2. Current documentation suggests stream methods should not be on collection
> interfaces to not bloat them since there is no single stream implementation.
>
> e.g. products.stream() vs products.parallel()
I understand this. But the result is that we have to use an
intermediary method call that looks like noise addition in the method
chaining for the audience. This is not really intuitive.
> 3. May be they need not implicit parameters but primitive operation
> references?
>
> 3.1. java is explicit language (except `+` for String). `java` in IPA close
> to 'explicit' in several Slavic languages :)
>
> 3.2. when parameter is not needed method references `::` can be used.
I have explained the notion of method reference and the notation '::'.
It seems this was not sufficient :/
Thank for your feedback!
François-
> 2012/11/6 François Sarradin <fsarradin at xebia.fr>
>>
>> Hi,
>>
>> I know that you are looking for feedback. So during October, I
>> organized a presentation around the JSR335 at my company: Xebia
>> France. More precisely, it was an interactive session with a
>> presentation, some live coding and debates around the code, and a
>> retrospective. The audience was asked the impact of the Lambda Project
>> on the Java community and Java projects would probably be. I have
>> reported what has been said during my presentation on the blog of my
>> company:
>> http://blog.xebia.com/2012/11/05/report-will-java-8s-lambda-change-the-face-of-the-world/
>>
>> Regards,
>>
>> François Sarradin
>> Xebia IT Architects
>> http://www.xebia.fr
>> http://blog.xebia.fr
>>
>
More information about the lambda-dev
mailing list