Abstract
Java 8 retrofitted lambda expressions, a core feature of functional programming, into a mainstream object-oriented language with an imperative paradigm. However, we do not know how Java developers have adapted to the functional style of thinking, and more importantly, what are the reasons motivating Java developers to adopt functional programming. Without such knowledge, researchers miss opportunities to improve the state of the art, tool builders use unrealistic assumptions, language designers fail to improve upon their designs, and developers are unable to explore efficient and effective use of lambdas.
We present the first large-scale, quantitative and qualitative empirical study to shed light on how imperative programmers use lambda expressions as a gateway into functional thinking. Particularly, we statically scrutinize the source code of 241 open-source projects with 19,770 contributors, to study the characteristics of 100,540 lambda expressions. Moreover, we investigate the historical trends and adoption rates of lambdas in the studied projects. To get a complementary perspective, we seek the underlying reasons on why developers introduce lambda expressions, by surveying 97 developers who are introducing lambdas in their projects, using the firehouse interview method.
Among others, our findings revealed an increasing trend in the adoption of lambdas in Java: in 2016, the ratio of lambdas introduced per added line of code increased by 54% compared to 2015. Lambdas were used for various reasons, including but not limited to (i) making existing code more succinct and readable, (ii) avoiding code duplication, and (iii) simulating lazy evaluation of functions. Interestingly, we found out that developers are using Java's built-in functional interfaces inefficiently, i.e., they prefer to use general functional interfaces over the specialized ones, overlooking the performance overheads that might be imposed. Furthermore, developers are not adopting techniques from functional programming, e.g., currying. Finally, we present the implications of our findings for researchers, tool builders, language designers, and developers.
- Theodoros Amanatidis and Alexander Chatzigeorgiou. 2016. Studying the evolution of PHP web applications. Information and Software Technology 72 (2016), 48 – 67. DOI: Google Scholar
Digital Library
- A. Ampatzoglou, A. Chatzigeorgiou, S. Charalampidou, and P. Avgeriou. 2015. The Effect of GoF Design Patterns on Stability: A Case Study. IEEE Transactions on Software Engineering 41, 8 (Aug 2015), 781–802. DOI: Google Scholar
Digital Library
- Baeldung. 2016. Lambda Expressions and Functional Interfaces: Tips and Best Practices. (November 2016). http://www. baeldung.com/java-8-lambda-expressions-tipsGoogle Scholar
- Edd Barrett, Carl Friedrich Bolz-Tereick, Rebecca Killick, Sarah Mount, and Laurence Tratt. 2017. Virtual Machine Warmup Blows Hot and Cold. Proc. ACM Program. Lang. 1, OOPSLA (Oct. 2017).Google Scholar
Digital Library
- James M. Bieman, Greg Straw, Huxia Wang, P. Willard Munger, and Roger T. Alexander. 2003. Design Patterns and Change Proneness: An Examination of Five Evolving Systems. In Proceedings of the 9th International Symposium on Software Metrics (METRICS ’03). 40–49. http://dl.acm.org/citation.cfm?id=942804.943777Google Scholar
- Joshua Bloch. 2008. Effective Java: A Programming Language Guide. Addison-Wesley Professional.Google Scholar
- Viviana Bono, Enrico Mensa, and Marco Naddeo. 2014. Trait-oriented programming in Java 8. In 2014 International Conference on Principles and Practices of Programming on the Java Platform Virtual Machines, Languages and Tools, PPPJ ’14, Cracow, Poland, September 23-26, 2014. 181–186. DOI: Google Scholar
Digital Library
- Virginia Braun and Victoria Clarke. 2006. Using thematic analysis in psychology. Qualitative Research in Psychology 3, 2 (2006), 77–101. DOI: Google Scholar
Cross Ref
- Ian Bull. 2014. Eclipse Support for Java 8. (March 2014). http://eclipsesource.com/blogs/2014/03/25/ eclipse-support-for-java-8/Google Scholar
- John L. Campbell, Charles Quincy, Jordan Osserman, and Ove K. Pedersen. 2013. Coding In-depth Semistructured Interviews. Sociological Methods & Research 42, 3 (2013), 294–320. DOI: Google Scholar
Cross Ref
- Alonzo Church. 1932. A Set of Postulates for the Foundation of Logic. Annals of Mathematics 33, 2 (1932), 346–366. http://www.jstor.org/stable/1968337 Google Scholar
Cross Ref
- Michael Coblenz, Joshua Sunshine, Jonathan Aldrich, Brad Myers, Sam Weber, and Forrest Shull. 2016. Exploring Language Support for Immutability. In Proceedings of the 38th International Conference on Software Engineering (ICSE ’16). 736–747. DOI: Google Scholar
Digital Library
- Diego Costa, Artur Andrzejak, Janos Seboek, and David Lo. 2017. Empirical Study of Usage and Performance of Java Collections. In Proceedings of the 8th ACM/SPEC on International Conference on Performance Engineering (ICPE ’17). 389–400. DOI: Google Scholar
Digital Library
- Daniela S. Cruzes and Tore Dybå. 2011. Research synthesis in software engineering: A tertiary study. Information and Software Technology 53, 5 (May 2011), 440–455. DOI: Google Scholar
Digital Library
- Anthony H. Dekker. 2006. Lazy Functional Programming in Java. SIGPLAN Notices 41, 3 (March 2006), 30–39. DOI: Google Scholar
Digital Library
- Eclipse Java development tools. 2017. JDT Components. (2017). http://www.eclipse.org/jdt/Google Scholar
- Robert Dyer, Hridesh Rajan, Hoan Anh Nguyen, and Tien N. Nguyen. 2014. Mining Billions of AST Nodes to Study Actual and Potential Usage of Java Language Features. In Proceedings of the 36th International Conference on Software Engineering (ICSE 2014). 779–790. DOI: Google Scholar
Digital Library
- Steve Easterbrook, Janice Singer, Margaret-Anne Storey, and Daniela Damian. 2008. Selecting Empirical Methods for Software Engineering Research. Springer London, 285–311. DOI: Google Scholar
Cross Ref
- Lukas Eder. 2014. jOOλ - The Missing Parts in Java 8. (2014). https://github.com/jOOQ/jOOLGoogle Scholar
- Lyle Franklin, Alex Gyori, Jan Lahoda, and Danny Dig. 2013. LAMBDAFICATOR: From Imperative to Functional Programming Through Automated Refactoring. In Proceedings of the 2013 International Conference on Software Engineering (ICSE ’13). 1287–1290. Google Scholar
Cross Ref
- Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides. 1994. Design Patterns: Elements of Reusable Object-Oriented Software. Addison-Wesley Professional.Google Scholar
Digital Library
- Trisha Gee. 2015. Debugger Improvements. (November 2015). https://www.youtube.com/watch?v=rimzOolGguoGoogle Scholar
- Brian Goetz. 2012. Translation of Lambda Expressions. (April 2012). http://cr.openjdk.java.net/~briangoetz/lambda/ lambda-translation.htmlGoogle Scholar
- Alex Gyori, Lyle Franklin, Danny Dig, and Jan Lahoda. 2013. Crossing the gap from imperative to functional programming through refactoring. In ACM SIGSOFT Symposium on the Foundations of Software Engineering (ESEC/FSE). 543–553. Google Scholar
Digital Library
- Jerry L. Hintze and Ray D. Nelson. 1998. Violin Plots: A Box Plot-Density Trace Synergism. The American Statistician 52, 2 (1998), 181–184.Google Scholar
- IntelliJ. 2017. Migrating to Java 8. (April 2017). https://www.jetbrains.com/help/idea/2017.1/migrating-to-java-8.htmlGoogle Scholar
- JavaParser. 2017. Java 9 Parser and Abstract Syntax Tree for Java. (2017). http://javaparser.org/Google Scholar
- Foutse Khomh and Yann-Gaël Guéhéneuc. 2008. Do Design Patterns Impact Software Quality Positively?. In 12th European Conference on Software Maintenance and Reengineering. 274–278. DOI: Google Scholar
Digital Library
- Sergey Kuksenko. 2013. JDK 8: Lambda Performance study. (2013). http://www.oracle.com/technetwork/java/ jvmls2013kuksen-2014088.pdfGoogle Scholar
- Henry B. Mann. 1945. Nonparametric Tests Against Trend. Econometrica 13, 3 (1945), 245–259. Google Scholar
Cross Ref
- Radu Marinescu. 2004. Detection Strategies: Metrics-Based Rules for Detecting Design Flaws. In Proceedings of the 20th IEEE International Conference on Software Maintenance (ICSM ’04). 350–359. Google Scholar
Cross Ref
- Davood Mazinanian, Ameya Ketkar, Nikolaos Tsantalis, and Danny Dig. 2017. Supplemental material. (2017). http: //dmazinanian.me/conference-papers/oopsla/2017/07/04/oopsla17.htmlGoogle Scholar
- Bartłomiej Mazur. 2017. Performance of Java, part 2. (2017). https://blog.gotofinal.com/java/benchmark/performance/2017/ 07/09/performance-of-java-1.htmlGoogle Scholar
- Erik Meijer and Sigbjorn Finne. 2001. Lambada, Haskell as a better Java. Electronic Notes in Theoretical Computer Science 41, 1 (2001), 91 – 119. DOI: Google Scholar
Cross Ref
- Emerson Murphy-Hill, Chris Parnin, and Andrew P. Black. 2009. How We Refactor, and How We Know It. In Proceedings of the 31st International Conference on Software Engineering (ICSE ’09). 287–297. DOI: Google Scholar
Digital Library
- Emerson Murphy-Hill, Thomas Zimmermann, Christian Bird, and Nachiappan Nagappan. 2015. The Design Space of Bug Fixes and How Developers Navigate It. IEEE Transactions on Software Engineering 41, 1 (Jan 2015), 65–81. DOI: Google Scholar
Digital Library
- T. H. Ng, S. C. Cheung, W. K. Chan, and Y. T. Yu. 2007. Do Maintainers Utilize Deployed Design Patterns Effectively?. In Proceedings of the 29th International Conference on Software Engineering (ICSE ’07). 168–177. DOI: Google Scholar
Digital Library
- Adel Noureddine and Ajitha Rajan. 2015. Optimising Energy Consumption of Design Patterns. In Proceedings of the 37th International Conference on Software Engineering (ICSE ’15). 623–626. http://dl.acm.org/citation.cfm?id=2819009.2819120Google Scholar
Cross Ref
- Scott Oaks. 2014. Java Performance: The Definitive Guide: Getting the Most Out of Your Code. O’Reilly Media.Google Scholar
- Oracle. 2013. Java SE 8: Lambda Quick Start. (December 2013). http://www.oracle.com/webfolder/technetwork/tutorials/ obe/java/Lambda-QuickStart/index.htmlGoogle Scholar
- Oracle. 2014. Optional ( Java 8 Documentation). (2014). https://docs.oracle.com/javase/8/docs/api/java/util/Optional.htmlGoogle Scholar
- Oracle. 2015a. Lambda Expressions. (2015). https://docs.oracle.com/javase/tutorial/java/javaOO/lambdaexpressions.htmlGoogle Scholar
- Oracle. 2015b. Type Inference. (2015). https://docs.oracle.com/javase/tutorial/java/generics/genTypeInference.htmlGoogle Scholar
- V. Pankratius, F. Schmidt, and G. GarretÃşn. 2012. Combining functional and imperative programming for multicore software: An empirical study evaluating Scala and Java. In 2012 34th International Conference on Software Engineering (ICSE’12). 123–133. DOI: Google Scholar
Cross Ref
- Chris Parnin, Christian Bird, and Emerson Murphy-Hill. 2011. Java Generics Adoption: How New Features Are Introduced, Championed, or Ignored. In Proceedings of the 8th Working Conference on Mining Software Repositories (MSR ’11). 3–12. DOI: Google Scholar
Digital Library
- L. Prechelt, B. Unger, W. F. Tichy, P. Brössler, and L. G. Votta. 2001. A Controlled Experiment in Maintenance Comparing Design Patterns to Simpler Solutions. IEEE Transactions on Software Engineering 27, 12 (Dec. 2001), 1134–1144. DOI: Google Scholar
Digital Library
- Eric S. Raymond. 2001. The Cathedral and the Bazaar: Musings on Linux and Open Source by an Accidental Revolutionary. O’Reilly & Associates, Inc., Sebastopol, CA, USA.Google Scholar
- Romain Robbes, David Röthlisberger, and Éric Tanter. 2015. Object-oriented software extensions in practice. Empirical Software Engineering 20, 3 (2015), 745–782. DOI: Google Scholar
Digital Library
- Nathanael Schärli, Stéphane Ducasse, Oscar Nierstrasz, and Andrew P. Black. 2003. Traits: Composable Units of Behaviour. In Proceedings of the 17th European Conference on Object-Oriented Programming (ECOOP’03). 248–274. DOI: Google Scholar
Cross Ref
- Pranab Kumar Sen. 1968. Estimates of the Regression Coefficient Based on Kendall’s Tau. J. Amer. Statist. Assoc. 63, 324 (1968), 1379–1389. Google Scholar
Cross Ref
- Anton Setzer. 2003. Java as a Functional Programming Language. In : International Workshop of Types for Proofs and Programs (TYPES 2002). 279–298. DOI: Google Scholar
Cross Ref
- Danilo Silva, Nikolaos Tsantalis, and Marco Tulio Valente. 2016. Why We Refactor? Confessions of GitHub Contributors. In Proceedings of the 2016 24th ACM SIGSOFT International Symposium on Foundations of Software Engineering (FSE 2016). 858–870. DOI: Google Scholar
Digital Library
- Janice Singer, Susan E. Sim, and Timothy C. Lethbridge. 2008. Software Engineering Data Collection for Field Studies. In Guide to Advanced Empirical Software Engineering, Forrest Shull, Janice Singer, and Dag I. K. Sjøberg (Eds.). Springer London, Chapter 1, 9–34. Google Scholar
Cross Ref
- Ewan Tempero, Hong Yul Yang, and James Noble. 2013. What Programmers Do with Inheritance in Java. In Proceedings of the 27th European Conference on Object-Oriented Programming (ECOOP 2013). 577–601. DOI: Google Scholar
Digital Library
- TouK. 2017. ThrowingFunction. (2017). https://github.com/TouK/ThrowingFunctionGoogle Scholar
- Nikolaos Tsantalis, Davood Mazinanian, and Giri P. Krishnan. 2015. Assessing the Refactorability of Software Clones. IEEE Transactions on Software Engineering 41, 11 (Nov 2015), 1055–1090. DOI: Google Scholar
Digital Library
- Nikolaos Tsantalis, Davood Mazinanian, and Shahriar Rostami. 2017. Clone Refactoring with Lambda Expressions. In Proceedings of the 39th International Conference on Software Engineering (ICSE ’17). 60–70. DOI: Google Scholar
Digital Library
- Phillip Merlin Uesbeck, Andreas Stefik, Stefan Hanenberg, Jan Pedersen, and Patrick Daleiden. 2016. An Empirical Study on the Impact of C++ Lambdas and Programmer Experience. In Proceedings of the 38th International Conference on Software Engineering (ICSE ’16). 760–771. DOI: Google Scholar
Digital Library
- Marek Vokáč, Walter Tichy, Dag I. K. Sjøberg, Erik Arisholm, and Magne Aldrin. 2004. A Controlled Experiment Comparing the Maintainability of Programs Designed with and Without Design Patterns – A Replication in a Real Programming Environment. Empirical Software Engineering 9, 3 (Sept. 2004), 149–195. DOI: Google Scholar
Digital Library
- Geertjan Wielenga. 2014. Smart Migration to JDK 8 in NetBeans IDE. (January 2014). https://netbeans.org/kb/docs/java/ jdk8-migration-screencast.htmlGoogle Scholar
- Claes Wohlin and Aybüke Aurum. 2015. Towards a decision-making structure for selecting a research design in empirical software engineering. Empirical Software Engineering 20, 6 (2015), 1427–1455. DOI: Google Scholar
Digital Library
- Alex Zhitnitsky. 2015. Benchmark: How Misusing Streams Can Make Your Code 5 Times Slower. (2015). http://blog.takipi. com/benchmark-how-java-8-lambdas-and-streams-can-make-your-code-5-times-slower/Google Scholar
Index Terms
Understanding the use of lambda expressions in Java
Recommendations
Porting the NetBeans Java 8 enhanced for loop lambda expression refactoring to eclipse
SPLASH Companion 2015: Companion Proceedings of the 2015 ACM SIGPLAN International Conference on Systems, Programming, Languages and Applications: Software for HumanityJava 8 is one of the largest upgrades to the popular language and framework in over a decade. However, the Eclipse IDE is missing several key refactorings that could help developers take advantage of new features in Java 8 more easily. In this paper, ...
An Empirical Study on the Use and Misuse of Java 8 Streams
Fundamental Approaches to Software EngineeringAbstractStreaming APIs allow for big data processing of native data structures by providing MapReduce-like operations over these structures. However, unlike traditional big data systems, these data structures typically reside in shared memory accessed by ...
The indolent lambdification of Java: Understanding the support for lambda expressions in the Java ecosystem
AbstractAs Java 8 introduced functional interfaces and lambda expressions to the Java programming language, the JDK API was changed to introduce support for lambda expressions, thus allowing consumers to define lambda functions when using Java’s ...






Comments