A Functional Yield-Based Traversal Pattern for Concise, Composable, and Efficient Stream Pipelines

Read full text
Authors: Fernando Miguel Carvalho
Cited by: 0
References: 14

Abstract

The stream pipeline idiom provides a fluent and composable way to express computations over collections. It gained widespread popularity after its introduction in .NET in 2005, later influencing many platforms, including Java in 2014 with the introduction of Java Streams, and continues to be adopted in contemporary languages such as Kotlin. However, the set of operations available in standard libraries is limited, and developers often need to introduce operations that are not provided out of the box. Two options typically arise: implementing custom operations using the standard API or adopting a third-party collections library that offers a richer suite of operations. In this article, we show that both approaches may incur performance overhead, and that the former can also suffer from verbosity and reduced readability. We propose an alternative approach that remains faithful to the stream-pipeline pattern: developers implement the unit operations of the pipeline from scratch using a functional yield-based traversal pattern. We demonstrate that this approach requires low programming effort, eliminates the performance overheads of existing alternatives, and preserves the key qualities of a stream pipeline. Our experimental results show up to a 3× speedup over the use of native yield in custom extensions.

Fields of Study & Subjects

Logic programming and type systems Advanced Database Systems and Queries Parallel Computing and Optimization Techniques

Publication details

Journal / source
Software
Volume
5
Issue
1
Pages
7–7
Publication date
10 February 2026
Language
EN