easier work with collections: default Stream.toList?

Paulo Silveira paulo.silveira at caelum.com.br
Mon Sep 30 12:58:52 PDT 2013

Brian has already exposed the problems about including Stream.toList
and other methods, just as Paul Sandoz.

I do understand the points, but we are always forgetting the
newcomers: Java 8 will be a difficult language to master, and much
more difficult to learn the basics. list = list.stream().map( ...
).collect(Collectors.toList()) is not a friendly line of code to
someone who is learning Java.

Paulo Silveira

2013/9/30 Millies, Sebastian <Sebastian.Millies at softwareag.com>:
> I would count myself a medium experienced user (I've been practicing using the new constructs in Java 8
> from time to time for about half a year). I must say I'd value the purity of the stream interface much higher.
> I think it's important to look beyond the current release to what may happen farther away in the future.
> Tying streams to that horrible old API seems like a really bad idea to me. And what with IDE support and
> static imports, I can't say there'd be much of a conciseness advantage that would pay for the pollution.
> -- Sebastian
> -----Original Message-----
> From: lambda-dev-bounces at openjdk.java.net [mailto:lambda-dev-bounces at openjdk.java.net] On Behalf Of Paul Sandoz
> Sent: Monday, September 30, 2013 10:26 AM
> Cc: lambda-dev at openjdk.java.net
> Subject: Re: easier work with collections: default Stream.toList?
> [snip]
> The main reasons for resisting Stream.toList etc are:
>   1) It ties streams to the existing collections API; and
>   2) If we add a few then people may likely want more.
> i.e. pollution and not enough pollution respectively :-)
> I like the purity of streams.
> However, I find the arguments are persuasive for adding a few, say for List<T> and Map<K, List<T>> for common cases of toList and groupingBy. New users need not run into Collector immediately and for more experienced users it's just more concise.
> Paul.
> Software AG – Sitz/Registered office: Uhlandstraße 12, 64297 Darmstadt, Germany – Registergericht/Commercial register: Darmstadt HRB 1562 - Vorstand/Management Board: Karl-Heinz Streibich (Vorsitzender/Chairman), Dr. Wolfram Jost, Arnd Zinnhardt; - Aufsichtsratsvorsitzender/Chairman of the Supervisory Board: Dr. Andreas Bereczky - http://www.softwareag.com

More information about the lambda-dev mailing list