Operations would be more flexible and expansive under the proposal by the OpenJDK community. Credit: Felix Brönnimann Java’s stream operations would become more flexible and expressive and allow custom intermediate operations to manipulate streams of infinite size to the extent possible, under a proposal in the OpenJDK community. Authored this month and in a preview stage, the stream gatherers proposal would enhance Java’s Stream API to support custom intermediate operations. This would allow stream pipelines to transform data in ways not easily achievable with existing built-in intermediate operations. It is not the intent, though, to change the Java language to better facilitate stream processing or provide a special-case compilation of code that uses the Stream API. Stream::gather(Gatherer) is a new intermediate stream operation that processes elements of a stream by applying a user-defined entity called a gatherer. With the gather operation, developers can build efficient, parallel-ready streams implementing almost any intermediate operation. The proposal explains that Java 8, unveiled in March 2014, introduced the first API specifically for lambda expressions, the Stream API, java.util.stream. A stream is a lazily computed, potentially unbounded sequence of values. The API supports processing a stream either sequentially or in parallel. A stream pipeline consists of a source of elements, any number of intermediate operations, and a terminal operation. This programming is both expressive and efficient. With the builder-style API, each intermediate operation returns a new stream; evaluation begins only when a terminal operation is invoked. The Stream API provides a reasonably rich, albeit fixed set of intermediate and terminal operations, including mapping, filtering, reduction, sorting, and others. An extensible terminal operation, Stream::collect, also is featured, enabling the output of a pipeline to be summarized in multiple ways. Use of streams in the Java ecosystem now is pervasive. However, the fixed set of intermediate operations means some complex tasks cannot easily be expressed as stream pipelines. Either a required intermediate task operation does not exist, or it exists but does not directly support the task. Intended for the standard edition of Java, the soonest stream gatherers could appear in a formal edition would be in Java Development Kit (JDK) 22, which is in development now and set to appear in March 2023. Currently, the stream gatherers preview is not targeted to any specific version of standard Java. Related content news Go language evolving for future hardware, AI workloads The Go team is working to adapt Go to large multicore systems, the latest hardware instructions, and the needs of developers of large-scale AI systems. By Paul Krill Nov 15, 2024 3 mins Google Go Generative AI Programming Languages analysis And the #1 Python IDE is . . . PyCharm, VS Code, and five other popular Python IDEs duke it out. Which one do you think takes home the prize? By Serdar Yegulalp Nov 15, 2024 2 mins Python Programming Languages Software Development news JDK 24: The new features in Java 24 21 features are proposed for the next version of Java including quantum-resistant cryptographic keys designed to secure Java apps against future quantum computing attacks. By Paul Krill Nov 15, 2024 11 mins Java Programming Languages Software Development news Rust Foundation moves forward on C++ and Rust interoperability Problem statement released to address the challenges to making cross-language development with C++ and Rust more accessible and approachable. By Paul Krill Nov 14, 2024 2 mins C++ Rust Programming Languages Resources Videos