New Collection framework?

Stanislav Baiduzhyi sbaiduzh at redhat.com
Wed Feb 10 12:18:33 UTC 2016


On 10/02/16 12:55, Remi Forax wrote:
> Java 8 to the rescue :)
>
> The problem you have is that you don't know if the list is the result of a calculation or if it reflect an internal state thus has to be immutable.
> The idea is not to use the interface List in both cases, the result of a calculation should be a Stream and not a List, a Stream can be seen as the result of a calculation without specifying the collection doing the actual storage (before 8, the JDK tends to use java.util.Enumeration and then Iterator to represent the result of a calculation).
> So you should never think that it's safe to mutate a List you get as a return value of a method.

In perfect world yes, but in our world we have to wait for JPA and other 
persistence frameworks to catch up with Java 8 and give us some 
Stream-friendly APIs. For now we're still stuck with Guava ImmutableLists.

> as David says it was rule out when the collection API was created as too complex because you multiply the number of interfaces (not enough bangs for bucks),

Pity. Now instead of nice and clean interfaces we have loads of 
libraries providing the same often incompatible functionality and even 
different naming for the same things. Remind of famous comics at xkcb 
about 14 competing standards.

-- 
Regards,
     Stas



More information about the core-libs-dev mailing list