Round 1 feedback

Paul Sandoz paul.sandoz at
Wed Jan 9 03:59:40 PST 2013

Hi Michael,

Thanks for the feedback.

On Jan 9, 2013, at 12:06 PM, Michael Nascimento <misterm at> wrote:

> Hi guys,
> So last Friday I spent some time migrating the code from a heavily
> collection-based real world business project to JDK 8, as a way of
> seeing how it would work in practice. This project used Guava all over
> the place.
> Besides all the emails I've sent so far, here are a few pieces of
> extra feedback:
> - Code reduction was significant. My co-workers who have seen the code
> liked how well lambda is going;
> - There are still several constructions that require generics to be
> explicitly used, such as into(). Was not that the case, the reduction
> would have been even greater;

It's an ongoing task to improve the type inference of the compiler. Plus the error output at the moment is turned up to 11, it will be turned down later on.

> - There were two legacy methods in this code base that relied wrongly
> on double. When I changed the reduction to use parallelStream(), my
> unit tests failed miserably, since operations like sum are not
> commutative with doubles given their lake of precision. I guess this
> will bite developers out there. Somewhere in javadoc it could be worth
> mentioning how parallel execution might affect the output in this
> case;

When we add DoubleStream it will have a sum() method and we may be able to do something using:

> - The main transformation in the code base is taking an Entity and
> turning it into a Map<T, Entity> (Maps.uniqueIndex in Guava). In the
> binary drop that was available at that time, there was no easy way of
> achieving that. Is there any now in b72?;

I think it could be done using Reducers.groupBy, off the top of my head (from tip of the code base but IIRC it is currently the same as b72):

  Map<Foo, Entity> m = s.reduce(Reducers.groupBy(e->toFoo(e), e -> e, Reducers.THROWING_MERGER))

An ISE will be thrown if the same Foo key is produced for more than one Entity value.

I think we should encapsulate that pattern.

> - The other main Guava uses that remained were Multimaps - and there
> were many. Any plans to support them?;

Not currently. The Reducers.groupBy functionality seems to cover many cases where one might otherwise require a Multimap.

> - I was able to refactor parts of my code base in a way that wasn't
> practical before by using Block in method signatures. Of course it
> should be used wisely, but be ready to see this code smell spreading
> everywhere with Java 8.

> Overall, it was a very positive experience. I hope to continue with
> this experiment in a few weeks.



More information about the lambda-dev mailing list