easier work with collections: default Stream.toList?

Millies, Sebastian Sebastian.Millies at softwareag.com
Mon Sep 30 04:41:12 PDT 2013


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