Java 8 retrofitted lambda expressions, a core feature of functional programming, into a mainstream objectoriented 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 that motivate 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 two-fold compared to 2015. Lambdas are 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 generic 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. Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than the author(s) must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from permissions@acm.org.  Lambdas are the core features of the functional programming paradigm. Over the last years, several mainstream object-oriented languages, such as Java 8, C# 3 and C++ 11, added lambda expressions to facilitate the functional programming style, and the parameterization of behavior. The original intention of the Java language designers [Oracle 2013] behind the addition of lambda expressions was to provide a clear and concise way to represent one-method interfaces using an expression, improve the collections framework by providing an alternative way to iterate through, filter, and extract data from collections using streams, and improve performance in multi-core environments with new concurrency features using parallel streams. Since then, both researchers and IDE providers [Bull 2014; IntelliJ 2017; Wielenga 2014] developed tools to automatically refactor code to take advantage of lambda expressions. The adoption of these tools facilitates the migration from anonymous classes to lambda expressions, and from enhanced for loops to streams. Moreover, IDE providers improved substantially their debugging support for lambda expressions [Gee 2015] , by allowing to set breakpoints for and step into lambda expressions. Despite the growing tool support for lambda expressions in Java IDEs, there is still limited empirical evidence about the adoption of lambdas by Java developers, the actual reasons that motivate or discourage Java developers from using lambdas, and the practices applied by Java developers when using lambdas. The lack of this knowledge impacts negatively four audiences:
On the other hand, Mazinanina REF focused on the evolution trend of only one feature, investigating the usage of Lambda in Java.
Understanding the use of lambda expressions in Java
PACMPL
Computer Science