Understanding the Impact of Introducing Lambda Expressions in Java Programs


  • Walter Lucas Monteiro Mendonça University of Brasilia
  • José Fortes University of Brasília (UnB)
  • Francisco Vitor Lopes University of Brasília (UnB)
  • Diego Marcílio Università della Svizzera italiana
  • Rodrigo Bonifácio de Almeida University of Brasília (UnB)
  • Edna Dias Canedo University of Brasília (UnB)
  • Fernanda Lima University of Brasília (UnB)
  • João Saraiva University of Minho




Background: The Java programming language version eight introduced several features that encourage the functional style of programming, including the support for lambda expressions and the Stream API. Currently, there is common wisdom that refactoring legacy code to introduce lambda expressions, besides other potential benefits, simplifies the code and improves program comprehension. Aims: The purpose of this work is to investigate this belief, conducting an in-depth study to evaluate the effect of introducing lambda expressions on program comprehension. Method: We conduct this research using a mixed-method study. For the quantitative method, we quantitatively analyze 166 pairs of code snippets extracted directly either from GitHub or from recommendations from three tools (RJTL, NetBeans, and IntelliJ). We also surveyed practitioners to collect their perceptions about the benefits on program comprehension when introducing lambda expressions. We asked practitioners to evaluate and rate sets of pairs of code snippets. Results: We found contradictory results in our research. Based on the quantitative assessment, we could not find evidence that the introduction of lambda expressions improves software readability—one of the components of program comprehension. Our results suggest that the transformations recommended by the aforementioned tools decrease program comprehension when assessed by two state-of-the-art models to estimate readability. Differently, our findings of the qualitative assessment suggest that the introduction of lambda expression improves program comprehension in three scenarios: when we convert anonymous inner classes to a lambda expression, structural loops with inner conditional to a anyMatch operator, and structural loops to filter operator combined with a collect method. Implications: We argue in this paper that one can improve program comprehension when she applies particular transformations to introduce lambda expressions (e.g., replacing anonymous inner classes with lambda expressions). Also, the opinion of the participants shines the opportunities in which a transformation for introducing lambda might be advantageous. This might support the implementation of effective tools for automatic program transformations.


Download data is not yet available.


Alqaimi, A., Thongtanunam, P., and Treude, C. (2019). Au­tomatically generating documentation for lambda expres­sions in java. In Proceedings of the 16th International Conference on Mining Software Repositories, MSR ’19, pages 310–320, Piscataway, NJ, USA. IEEE Press.

Avidan, E. and Feitelson, D. G. (2017). Effects of variable names on comprehension an empirical study. In Scan­niello, G., Lo, D., and Serebrenik, A., editors, Proceedings of the 25th International Conference on Program Comprehension, ICPC 2017, BuenosAires, Argentina, May 22­-23, 2017, pages 55–65. IEEE Computer Society.

Baggen, R., Correia, J. P., Schill, K., and Visser, J. (2012).Standardized code quality benchmarking for improving software maintainability. Software Quality Journal, 20(2):287–307.

Buse, R. P. L. and Weimer, W. (2010). Automatically doc­umenting program changes. In Pecheur, C., Andrews, J., and Nitto, E. D., editors, ASE2010, 25th IEEE/ACM Inter­national Conference on Automated Software Engineering, Antwerp, Belgium, September 20­24, 2010, pages 33–42. ACM.

Carvalho, A., Luz, W. P., Marcilio, D., Bonifácio, R., Pinto,G., and Canedo, E. D. (2020). C­3PR: A bot for fixing static analysis violations via pull requests. In Kontogian­nis, K., Khomh, F., Chatzigeorgiou, A., Fokaefs, M., and Zou, M., editors,27th IEEE International Conference on software Analysis, Evolution and Reengineering, SANER2020, London, ON, Canada, February 18­21, 2020, pages161–171. IEEE.

Dantas, R., Carvalho, A., Marcilio, D., Fantin, L., Silva, U.,Lucas, W., and Bonifácio, R. (2018). Reconciling the past and the present: An empirical study on the applica­tion of source code transformations to automatically re­juvenate java programs. In Oliveto, R., Penta, M. D., and shepherd, D. C., editors, 25th International Conference on Software Analysis, Evolution and Reengineering, SANER2018, Campobasso, Italy, March 20­23, 2018, pages 497–501. IEEE Computer Society.

dos Santos, R. M. and Gerosa, M. A. (2018). Impacts of coding practices on readability. In Khomh, F., Roy, C. K., and Siegmund, J., editors, Proceedings of the 26th Con­ferenceonProgramComprehension, ICPC 2018, Gothen­burg, Sweden, May 27­28, 2018, pages 277–285. ACM.

Fakhoury, S., Roy, D., Hassan, S. A., and Arnaoudova, V.(2019). Improving source code readability: Theory and practice. InProceedings of the 27th International Confer­ence on Program Comprehension, ICPC ’19, pages 2–12, Piscataway, NJ, USA. IEEE Press.

Favre, J.­M., Lämmel, R., Schmorleiz, T., and Varanovich,A. (2012). 101companies: A community project on soft­ware technologies and software languages. In Furia, C. A.and Nanz, S., editors,Objects, Models, Components, Pat­terns, pages 58–74, Berlin, Heidelberg. Springer Berlin Heidelberg.

Godfrey, M. W. and German, D. M. (2008). The past, present, and future of software evolution. In 2008 Fron­tiers of Software Maintenance, pages 129–138.

Gopstein, D., Iannacone, J., Yan, Y., DeLong, L., Zhuang, Y., Yeh, M. K.­C., and Cappos, J. (2017). Understanding misunderstandings in source code. In Proceedings of the 2017 11th Joint Meeting on Foundations of Software En­gineering, ESEC/FSE 2017, pages 129–139, New York, NY, USA. ACM.

Gyori, A., Franklin, L., Dig, D., and Lahoda, J. (2013). Crossing the gap from imperative to functional program­ming through refactoring. In Proceedings of the 2013 9th Joint Meeting on Foundations of Software Engineering, ESEC/FSE 2013, pages 543–553, New York, NY, USA.ACM.

Khatchadourian, R., Tang, Y., Bagherzadeh, M., and Ahmed,S. (2019). Safe automated refactoring for intelligent par­allelization of Java 8 streams. In Proceedings of the 41st International Conference on Software Engineering, ICSE’19, pages 619–630, Piscataway, NJ, USA. IEEE Press.

Landman, D., Serebrenik, A., Bouwers, E., and Vinju, J. J.(2016). Empirical analysis of the relationship between CC and SLOC in a large corpus of java methods and C functions.Journal of Software: Evolution and Process,28(7):589–618.

Lehman, M. M. and Ramil, J. F. (2001). Rules and tools for software evolution planning and management.Annals of software engineering, 11(1):15–44.

Lott, S. F. (2018).Functional Python Programming: Dis­cover the power of functional programming, generator functions, lazy evaluation, the built­-in itertools library, and monads. Packt Publishing Ltd.

Lucas, W., Bonifácio, R., Canedo, E. D., Marcilio, D., andLima, F. (2019). Does the introduction of lambda expres­sions improve the comprehension of java programs? Indo Carmo Machado, I., Souza, R., Maciel, R. S. P., and Santanna, C., editors, Proceedings of the XXXIII Brazilian Symposium on Software Engineering, SBES2019, Sal­vador, Brazil, September 23­27, 2019, pages 187–196.ACM.

Mazinanian, D., Ketkar, A., Tsantalis, N., and Dig, D. (2017).Understanding the use of lambda expressions in java. Proc. ACM Program. Lang., 1(OOPSLA):85:1–85:31.

Mukaka, M. M. (2012). A guide to appropriate use of cor­relation coefficient in medical research.Malawi medicaljournal, 24(3):69–71.

Overbey, J. L. and Johnson, R. E. (2009). Regrowing a lan­guage: Refactoring tools allow programming languages to evolve. In Proceedings of the 24th ACM SIGPLAN Con­ference on Object Oriented Programming Systems Lan­guages and Applications, OOPSLA ’09, pages 493–502, New York, NY, USA. ACM.

Parr, T. and Vinju, J. J. (2016). Towards a universal code formatted through machine learning. In van der Storm, T., Balland, E., and Varró, D., editors, Proceedings of the 2016 ACM SIGPLAN International Conference onSoftwareLanguageEngineering, Amsterdam, The Nether­lands, October 31 ­ November 1, 2016, pages 137–151. ACM.

Pennington, N. (1987). Stimulus structures and mental rep­resentations in expert comprehension of computer pro­grams. Cognitive Psychology, 19(3):295 – 341.

Posnett, D., Hindle, A., and Devanbu, P. T. (2011). A sim­pler model of software readability. In van Deursen, A.,Xie, T., and Zimmermann, T., editors, Proceedings of the 8th International Working Conference on Mining Software Repositories, MSR 2011 (Co­located with ICSE), Waikiki,Honolulu, HI, USA, May 21­28, 2011, Proceedings, pages 73–82. ACM.

Riaz, M., Mendes, E., and Tempero, E. (2009). A systematic review of software maintainability prediction and metrics. In 2009 3rd International Symposium on Empirical Soft­ware Engineering and Measurement, pages 367–377.

Scalabrino, S., Linares-­Vásquez, M., Poshyvanyk, D., and Oliveto, R. (2016). Improving code readability modelswith textual features. In 2016 IEEE 24th International Conference on Program Comprehension (ICPC), pages 1–10.

Shrestha, N., Botta, C., Barik, T., and Parnin, C. (2020). Herewe go again: Why is it difficult for developers to learn an­other programming language? In Proceedings of the 42nd International Conference on Software Engineering, ICSE.

Silva, D., Tsantalis, N., and Valente, M. T. (2016). Why we refactor? confessions of github contributors. In Zim­mermann, T., Cleland-­Huang, J., and Su, Z., editors, Pro­ceedings of the 24th ACM SIGSOFT International Sympo­sium on Foundations of Software Engineering, FSE 2016, Seattle, WA, USA, November 13­-18, 2016, pages 858–870.ACM.

Storey, M. D., Wong, K., and Müller, H. A. (2000). How do program understanding tools affect how programmers un­derstand programs? Sci. Comput. Program., 36(2­3):183–207.

Stroustrup, B. (2013). The C++ Programming Language. Addison-­Wesley Professional, 4th edition.

Tilley, S. R., Paul, S., and Smith, D. B. (1996). Towards a framework for program understanding. In WPC ’96. 4th Workshop on Program Comprehension pages 19–28.

Tsantalis, N., Mazinanian, D., and Rostami, S. (2017). Clone refactoring with lambda expressions. In 2017 IEEE/ACM 39th International Conference on Software Engineering(ICSE), pages 60–70.

Urma, R.­G., Fusco, M., and Mycroft, A. (2014). Java 8 in Action: Lambdas, Streams, and functional ­style program­ming. Manning Publications Co.

von Mayrhauser, A. and Vans, A. M. (1995). Program com­prehension during software maintenance and evolution.IEEE Computer, 28(8):44–55.

Wilcoxon, F. (1945). Individual comparisons by ranking methods. Biometrics Bulletin (JSTOR), 1(6):80–83.




How to Cite

Mendonça, W. L. M., Fortes, J., Lopes, F. V., Marcílio, D., de Almeida, R. B., Canedo, E. D., Lima, F., & Saraiva, J. (2020). Understanding the Impact of Introducing Lambda Expressions in Java Programs. Journal of Software Engineering Research and Development, 8, 7:1 – 7:22. https://doi.org/10.5753/jserd.2020.744



Research Article