{"status":"ok","message-type":"work","message-version":"1.0.0","message":{"indexed":{"date-parts":[[2026,2,11]],"date-time":"2026-02-11T13:01:03Z","timestamp":1770814863152,"version":"3.50.1"},"reference-count":38,"publisher":"MDPI AG","issue":"1","license":[{"start":{"date-parts":[[2026,2,10]],"date-time":"2026-02-10T00:00:00Z","timestamp":1770681600000},"content-version":"vor","delay-in-days":0,"URL":"https:\/\/creativecommons.org\/licenses\/by\/4.0\/"}],"content-domain":{"domain":[],"crossmark-restriction":false},"short-container-title":["Software"],"abstract":"<jats:p>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\u00d7 speedup over the use of native yield in custom extensions.<\/jats:p>","DOI":"10.3390\/software5010007","type":"journal-article","created":{"date-parts":[[2026,2,11]],"date-time":"2026-02-11T09:16:08Z","timestamp":1770801368000},"page":"7","update-policy":"https:\/\/doi.org\/10.3390\/mdpi_crossmark_policy","source":"Crossref","is-referenced-by-count":0,"title":["A Functional Yield-Based Traversal Pattern for Concise, Composable, and Efficient Stream Pipelines"],"prefix":"10.3390","volume":"5","author":[{"ORCID":"https:\/\/orcid.org\/0000-0002-4281-3195","authenticated-orcid":false,"given":"Fernando Miguel","family":"Carvalho","sequence":"first","affiliation":[{"name":"Instituto Superior de Engenharia de Lisboa, Instituto Polit\u00e9cnico de Lisboa, Rua Conselheiro Em\u00eddio Navarro 1, 1959-007 Lisboa, Portugal"}]}],"member":"1968","published-online":{"date-parts":[[2026,2,10]]},"reference":[{"key":"ref_1","unstructured":"Fowler, M. (2025, November 14). Collection Pipeline. Available online: https:\/\/martinfowler.com\/articles\/collection-pipeline."},{"key":"ref_2","unstructured":"Goetz, B. (2025, November 14). Java Streams\u2014\u201cUnder the Hood\u201d. IBM Dev., Available online: https:\/\/developer.ibm.com\/articles\/j-java-streams-3-brian-goetz\/."},{"key":"ref_3","unstructured":"Michaelson, S., and Milner, R. (1976). CONS Should not Evaluate its Arguments. Automata, Languages and Programming, Edinburgh U. Press."},{"key":"ref_4","doi-asserted-by":"crossref","unstructured":"Wadler, P. (1988). Deforestation: Transforming programs to eliminate trees. European Symposium on Programming, Springer.","DOI":"10.1007\/3-540-19027-9_23"},{"key":"ref_5","first-page":"131","article-title":"Optimisation of language-integrated queries by query unnesting","volume":"47","author":"Kowalski","year":"2017","journal-title":"Comput. Lang. Syst. Struct."},{"key":"ref_6","first-page":"1","article-title":"Eliminating abstraction overhead of Java stream pipelines using ahead-of-time program optimization","volume":"4","author":"Veileborg","year":"2020","journal-title":"Proc. Acm Program. Lang."},{"key":"ref_7","doi-asserted-by":"crossref","unstructured":"Rosales, E., Ros\u00e0, A., Basso, M., Villaz\u00f3n, A., Orellana, A., Zenteno, \u00c1., Rivero, J., and Binder, W. (2022, January 26\u201330). Characterizing Java Streams in the Wild. Proceedings of the 2022 26th International Conference on Engineering of Complex Computer Systems (ICECCS), Hiroshima, Japan.","DOI":"10.1109\/ICECCS54210.2022.00025"},{"key":"ref_8","doi-asserted-by":"crossref","unstructured":"Basso, M., Schiavio, F., Ros\u00e0, A., and Binder, W. (2022, January 26\u201330). Optimizing Parallel Java Streams. Proceedings of the 2022 26th International Conference on Engineering of Complex Computer Systems (ICECCS), Hiroshima, Japan.","DOI":"10.1109\/ICECCS54210.2022.00012"},{"key":"ref_9","doi-asserted-by":"crossref","unstructured":"Rosales, E., Basso, M., Ros\u00e0, A., and Binder, W. (2023). Profiling and optimizing java streams. arXiv.","DOI":"10.22152\/programming-journal.org\/2023\/7\/10"},{"key":"ref_10","unstructured":"Dietrich, D. (2025, November 14). Vavr\u2014An Object-Functional Language Extension to Java 8. Technical Report, vavr.io. Available online: https:\/\/github.com\/vavr-io\/vavr."},{"key":"ref_11","unstructured":"Eder, L. (2025, November 14). JOOL\u2014The Missing Parts in Java 8. Technical Report, jOOQ. Available online: https:\/\/github.com\/jOOQ\/jOOL."},{"key":"ref_12","unstructured":"Eclipse Foundation (2025, November 14). Eclipse Collections. Technical Report. Available online: https:\/\/eclipse.dev\/collections\/."},{"key":"ref_13","unstructured":"Bourrillion, K., and Levy, J. (2025, November 14). Guava\u2014Google Core Libraries for Java. Technical Report, Google. Available online: http:\/\/github.com\/google\/guava."},{"key":"ref_14","unstructured":"Fox, D. (2025, November 14). protonpack\u2014Stream Utilities for Java 8. Technical Report, Codepoetics.com\/. Available online: https:\/\/github.com\/poetix\/protonpack."},{"key":"ref_15","unstructured":"Valeev, T. (2025, November 14). StreamEx\u2014Enhancing Java 8 Streams. Technical Report. Available online: https:\/\/github.com\/amaembo\/streamex."},{"key":"ref_16","unstructured":"Gamma, E., Helm, R., Johnson, R., and Vlissides, J. (1994). Design Patterns: Elements of Reusable Object-Oriented Software, Pearson Deutschland GmbH."},{"key":"ref_17","doi-asserted-by":"crossref","first-page":"18","DOI":"10.1145\/165507.165514","article-title":"Iterators: Signs of Weakness in Object-oriented Languages","volume":"4","author":"Baker","year":"1993","journal-title":"SIGPLAN OOPS Mess."},{"key":"ref_18","unstructured":"James, R., and Sabry, A. (2011). Yield: Mainstream Delimited Continuations. Workshop on the Theory and Practice of Delimited Continuations, Indiana University."},{"key":"ref_19","unstructured":"Odersky, M., Spoon, L., Venners, B., and Sommers, F. (2021). Programming in Scala, Fifth Edition: Updated for Scala 3, Artima Incorporation."},{"key":"ref_20","unstructured":"Akhin, M., and Belyaev, M. (2026, February 01). Kotlin Language Specification. Available online: https:\/\/kotlinlang.org\/spec\/pdf\/kotlin-spec.pdf."},{"key":"ref_21","unstructured":"Gamboa, M. (2025). The Managed Runtime Environment: Diving into the JVM with Kotlin, Leanpub."},{"key":"ref_22","doi-asserted-by":"crossref","unstructured":"Gabriel, R.P. (1991). The Design of Parallel Programming Languages. Artificial Intelligence and Mathematical Theory of Computation: Papers in Honor of John McCarthy, Academic Press Professional, Inc.","DOI":"10.1016\/B978-0-12-450010-5.50012-8"},{"key":"ref_23","unstructured":"Shipilev, A. (2026, February 01). Java Microbenchmark Harness (The Lesser of Two Evils). Available online: https:\/\/shipilev.net\/blog\/2014\/nanotrusting-nanotime\/."},{"key":"ref_24","doi-asserted-by":"crossref","first-page":"396","DOI":"10.1145\/366663.366704","article-title":"Design of a Separable Transition-Diagram Compiler","volume":"6","author":"Conway","year":"1963","journal-title":"Commun. ACM"},{"key":"ref_25","unstructured":"Liskov, B. (1983). CLU Reference Manual, Springer, Inc."},{"key":"ref_26","doi-asserted-by":"crossref","unstructured":"Griswold, R.E., and Griswold, M.T. (1996). History of the Icon programming language. History of Programming Languages\u2014II, Association for Computing Machinery.","DOI":"10.1145\/234286.1057830"},{"key":"ref_27","unstructured":"Borins, M., Braun, A.R., Palmer, R., and Terlson, B. (2006). ECMA-334 C# Language Specification, ECMA. [5th ed.]."},{"key":"ref_28","unstructured":"Thomas, D., and Hunt, A. (2007). Programming Ruby: The Pragmatic Programmer\u2019s Guide, Addison-Wesley."},{"key":"ref_29","doi-asserted-by":"crossref","first-page":"308","DOI":"10.1093\/comjnl\/6.4.308","article-title":"The Mechanical Evaluation of Expressions","volume":"6","author":"Landin","year":"1964","journal-title":"Comput. J."},{"key":"ref_30","doi-asserted-by":"crossref","first-page":"89","DOI":"10.1145\/363744.363749","article-title":"Correspondence Between ALGOL 60 and Church\u2019s Lambda-notation: Part I","volume":"8","author":"Landin","year":"1965","journal-title":"Commun. ACM"},{"key":"ref_31","unstructured":"Jones, S. (2003). Haskell 98 Language and Libraries: The Revised Report, Cambridge University Press."},{"key":"ref_32","doi-asserted-by":"crossref","first-page":"553","DOI":"10.1145\/359763.359782","article-title":"Abstraction and Verification in Alphard: Defining and Specifying Iteration and Generators","volume":"20","author":"Shaw","year":"1977","journal-title":"Commun. ACM"},{"key":"ref_33","unstructured":"Yee, K.P., and van Rossum, G. (2026, February 01). PEP 234\u2013Iterators. Available online: https:\/\/www.python.org\/dev\/peps\/pep-0234\/."},{"key":"ref_34","unstructured":"Prokopec, A., and Liu, F. (2018, January 16\u201321). Theory and Practice of Coroutines with Snapshots. Proceedings of the European Conference on Object-Oriented Programming, Amsterdam, The Netherlands."},{"key":"ref_35","doi-asserted-by":"crossref","unstructured":"Poeira, D., and Carvalho, F.M. (2021, January 6\u20138). Deconstructing yield operator to enhance streams processing. Proceedings of the ICSOFT 2021: 16th International Conference on Software Technologies, Paris, France.","DOI":"10.5220\/0010541000002992"},{"key":"ref_36","doi-asserted-by":"crossref","first-page":"1","DOI":"10.1145\/321738.321739","article-title":"Upper Bounds for the Total Path Length of Binary Trees","volume":"20","author":"Wong","year":"1973","journal-title":"J. ACM"},{"key":"ref_37","first-page":"263","article-title":"An algorithm for organization of information","volume":"146","author":"Landis","year":"1962","journal-title":"Dokl. Akad. Nauk SSSR"},{"key":"ref_38","doi-asserted-by":"crossref","unstructured":"Kiselyov, O., Biboudis, A., Palladinos, N., and Smaragdakis, Y. (2017, January 15\u201321). Stream fusion, to completeness. Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming Languages, Paris, France.","DOI":"10.1145\/3009837.3009880"}],"container-title":["Software"],"original-title":[],"language":"en","link":[{"URL":"https:\/\/www.mdpi.com\/2674-113X\/5\/1\/7\/pdf","content-type":"unspecified","content-version":"vor","intended-application":"similarity-checking"}],"deposited":{"date-parts":[[2026,2,11]],"date-time":"2026-02-11T10:13:05Z","timestamp":1770804785000},"score":1,"resource":{"primary":{"URL":"https:\/\/www.mdpi.com\/2674-113X\/5\/1\/7"}},"subtitle":[],"short-title":[],"issued":{"date-parts":[[2026,2,10]]},"references-count":38,"journal-issue":{"issue":"1","published-online":{"date-parts":[[2026,3]]}},"alternative-id":["software5010007"],"URL":"https:\/\/doi.org\/10.3390\/software5010007","relation":{},"ISSN":["2674-113X"],"issn-type":[{"value":"2674-113X","type":"electronic"}],"subject":[],"published":{"date-parts":[[2026,2,10]]}}}