The Java Collections Framework will be 15 years old by the time Java 8 ships, and although it has worn well, some of its underlying assumptions are increasingly called into question by changes in the environment in which Java programs are executed. The biggest change is in the hardware environment, where designers have turned their attention away from increasing the clock speed of individual cores and towards the goal of placing increasingly large numbers of cores on to the same chip. To gain the performance improvement potentially available from massively multicore processors, applications have to be able to divide their workload among many different threads, with each thread being capable of running independently on its “own” core. Library designers need to turn their attention to enabling this change, and since in many Java programs the most intensive activity is bulk processing of collection elements, the Java Collections Framework is at the center of this change.
Analysis of the usage of the Java collections shows one pattern to be very common, in which bulk operations draw from a data source (array or collection), then repeatedly apply transformation operations like filtering and mapping to the data, often finally summarising it in a single operation such as summing numeric elements. Current use of this pattern requires the creation of temporary collections to hold the intermediate results of these transformations. However, this style of processing can be recast to a pipeline using the well-known “Pipes and Filters” pattern, with significant resulting advantages: elimination of intermediate variables, reduction of intermediate storage, lazy evaluation, and more flexible and composable operation definitions. Moreover, if each operation in the pipeline is defined appropriately, the pipeline as a whole can often be automatically parallelised (split up for parallel execution on multicore processors). The role of pipes, the connectors between pipeline operations, is taken in the Java 8 libraries by implementations of the Stream interface; examining this interface will clarify how pipelines work.
This is the emphasis for evolution of the Java Collections Framework in Java 8. It will result in a more functional style of programming collections, replacing in-place mutation of values with the idioms defined by the methods of the Stream interface.