Advertisement

Programmers do not favor lambda expressions for concurrent object-oriented code

  • Sebastian Nielebock
  • Robert Heumüller
  • Frank Ortmeier
Article

Abstract

Lambda expressions have long been state-of-the-art in the functional programming paradigm. Especially with regard to the use of higher-order functions, they provide developers with a means of defining predicate or projection functions locally, which greatly increases the comprehensibility of the resulting source code. This benefit has motivated language designers to also incorporate lambda expressions into object-oriented (OO) programming languages. In particular, they are claimed to facilitate concurrent programming. One likely reason for this assumption is their purity: pure lambda expressions are free of side effects, and therefore cannot cause, e.g., race conditions. In this paper, we present the first empirical analysis of whether or not this claim is true for OO projects. For this purpose, we investigated the application of lambda expressions in 2923 open-source projects, implemented in one of the most common OO programming languages: C#, C++, and Java. We present three major findings. First, the majority of lambda expressions are not applied in concurrent code and most concurrent code does not make use of lambda expressions. Second, for all three of the languages, we observed that developers compromise their code by applying a significantly higher number of impure, capturing lambda expressions, which are capable of causing race conditions. Finally, we explored further use cases of lambda expressions and found out that testing, algorithmic implementation, and UI are far more common use-cases for the application of lambda expressions. Our results encourage to investigate in more detail the reasons that hinder programmers to apply lambda expressions in concurrent programming and to support developers, e.g., by providing automatic refactorings.

Keywords

Lambda expression Concurrency Object-orientation Programming language 

References

  1. Barr M (1999) Programming embedded systems in C and C++. O’Reilly Media, Inc, SebastopolGoogle Scholar
  2. Bavota G, Gethers M, Oliveto R, Poshyvanyk D, de Lucia A (2014) Improving software modularization via automated analysis of latent topics and dependencies. ACM Trans Softw Eng Methodol (TOSEM) 23(1):4:1–4:33.  https://doi.org/10.1145/2559935 CrossRefGoogle Scholar
  3. Ben-Ari M (2006) Principles of concurrent and distributed programming, 2nd edn. Pearson Education Limited, EnglandzbMATHGoogle Scholar
  4. Borges H, Hora A, Valente MT (2016) Understanding the factors that impact the popularity of GitHub repositories. In: Proceedings of the 32nd IEEE international conference on software maintenance and evolution (ICSME). IEEE, pp 334–344.  https://doi.org/10.1109/ICSME.2016.31
  5. Coblenz M, Sunshine J, Aldrich J, Myers B, Weber S, Shull F (2016) Exploring language support for immutability. In: Proceedings of the 38th international conference on software engineering (ICSE). ACM, New York, pp 736–747.  https://doi.org/10.1145/2884781.2884798
  6. Coblenz M, Nelson W, Aldrich J, Myers B, Sunshine J (2017) Glacier: transitive class immutability for java. In: Proceedings of the 39th international conference of software engineering (ICSE). IEEE Press, Piscataway, pp 496–506.  https://doi.org/10.1109/ICSE.2017.52
  7. Costa D, Andrzejak A, Seboek J, Lo D (2017) Empirical study of usage and performance of java collections. In: Proceedings of the 8th ACM/SPEC on international conference on performance engineering (ICPE). ACM, New York, pp 389–400.  https://doi.org/10.1145/3030207.3030221
  8. De Wael M, Marr S, Van Cutsem T (2014) Fork/join parallelism in the wild: documenting patterns and anti-patterns in java programs using the fork/join framework. In: Proceedings of the 11th international conference on principles and practices of programming on the java platform: virtual machines, languages, and tools (PPPJ). ACM, New York, pp 39–50.  https://doi.org/10.1145/2647508.2647511
  9. Dekker AH (2006) Lazy functional programming in java. ACM SIGPLAN Not 41(3):30–39.  https://doi.org/10.1145/1140543.1140549 CrossRefGoogle Scholar
  10. Dyer R, Rajan H, Nguyen HA, Nguyen TN (2013) A large-scale empirical study of java language feature usage. Tech. rep., Iowa State University. https://lib.dr.iastate.edu/cs_techreports/289/
  11. Dyer R, Rajan H, Nguyen HA, Nguyen TN (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). ACM, New York, pp 779–790.  https://doi.org/10.1145/2568225.2568295
  12. Dyer R, Nguyen HA, Rajan H, Nguyen TN (2015) Boa: ultra-large-scale software repository and source-code mining. ACM Trans Softw Eng Methodol 25(1):7:1–7:34CrossRefGoogle Scholar
  13. Franklin L, Gyori A, Lahoda J, Dig D (2013) LAMBDAFICATOR: from imperative to functional programming through automated refactoring. In: Proceedings of the 35th international conference on software engineering (ICSE). IEEE Press, Piscataway, pp 1287–1290. http://dl.acm.org/citation.cfm?id=2486788.2486986
  14. Garcia R, Jarvi J, Lumsdaine A, Siek JG, Willcock J (2003) A comparative study of language support for generic programming. In: Proceedings of the 18th annual ACM SIGPLAN conference on object-oriented programming, systems, languages, and applications (OOPSLA), pp 115–134Google Scholar
  15. Gu R, Jin G, Song L, Zhu L, Lu S (2015) What change history tells us about thread synchronization. In: Proceedings of the 10th joint meeting of the european software engineering conference and the ACM SIGSOFT symposium on the foundations of software engineering (ESEC/FSE). ACM, New York, pp 426–438.  https://doi.org/10.1145/2786805.2786815
  16. Gyori A, Franklin L, Dig D, Lahoda J (2013) Crossing the gap from imperative to functional programming through refactoring. In: Proceedings of the 9th joint meeting of the European software engineering conference and the ACM SIGSOFT symposium on the foundations of software engineering (ESEC/FSE). ACM, pp 543–553Google Scholar
  17. Hill E, Pollock L, Vijay-Shanker K (2009) Automatically capturing source code context of NL-queries for software maintenance and reuse. In: Proceedings of the 31st international conference on software engineering (ICSE). IEEE, pp 232–242Google Scholar
  18. Jarczyk O, Gruszka B, Jaroszewicz S, Bukowski L, Wierzbicki A (2014) GitHub projects. quality analysis of open-source software. In: Aiello LM, McFarland D (eds) Proceedings of the 6th international conference on social informatics (SocInfo). Springer International Publishing, Cham, pp 80–94.  https://doi.org/10.1007/978-3-319-13734-6_6
  19. Järvi J, Freeman J (2010) C++ lambda expressions and closures. Sci Comput Program 75(9):762–772MathSciNetCrossRefzbMATHGoogle Scholar
  20. Kim D, Murphy-Hill E, Parnin C, Bird C, Garcia R (2013) The reaction of open-source projects to new language features: an empirical study of C# generics. Journal of Object Technology 12(4):1:1–1:31CrossRefGoogle Scholar
  21. Kuhn A, Ducasse S, Gîrba T (2007) Semantic clustering: identifying topics in source code. Inf Softw Technol 49(3):230–243.  https://doi.org/10.1016/j.infsof.2006.10.017. http://www.sciencedirect.com/science/article/pii/S0950584906001820. 12th Working Conference on Reverse EngineeringCrossRefGoogle Scholar
  22. Lin Y, Dig D (2013) Check-then-act misuse of java concurrent collections. In: Proceedings of the 6th international conference on software testing, verification and validation (ICST). IEEE, pp 164–173Google Scholar
  23. Lin Y, Radoi C, Dig D (2014) Retrofitting concurrency for android applications through refactoring. In: Proceedings of the 22nd ACM SIGSOFT international symposium on foundations of software engineering (FSE). ACM, New York, pp 341–352.  https://doi.org/10.1145/2635868.2635903
  24. Marinescu C (2014) An empirical investigation on MPI open source applications. In: Proceedings of the 18th international conference on evaluation and assessment in software engineering (EASE). ACM, New York, pp 20:1–20:4.  https://doi.org/10.1145/2601248.2601298
  25. Martelli A, Ravenscroft A, Ascher D (eds) (2005) Python cookbook, vol 2. O’Reilly Media Inc, SebastopolGoogle Scholar
  26. Mazinanian D, Ketkar A, Tsantalis N, Dig D (2017) Understanding the use of lambda expressions in java. Proceedings of the ACM on Programming Languages 1 (OOPSLA):85:1–85:31.  https://doi.org/10.1145/3133909
  27. Meijer E, Finne S (2001) Lambada, Haskell as a better Java. Electron Notes Theor Comput Sci 41(1):91–119.  https://doi.org/10.1016/S1571-0661(05)80549-3. http://www.sciencedirect.com/science/article/pii/S1571066105805493. 2000 ACM SIGPLAN Haskell Workshop (Satellite Event of PLI 2000)CrossRefGoogle Scholar
  28. Miller W, Myers EW (1985) A file comparison program. Software: Practice and Experience 15(11):1025–1040Google Scholar
  29. Myers EW (1986) An O(ND) difference algorithm and its variations. Algorithmica 1(1–4):251–266MathSciNetCrossRefzbMATHGoogle Scholar
  30. Odersky M, Rompf T (2014) Unifying functional and object-oriented programming with scala. Commun ACM 57(4):76–86.  https://doi.org/10.1145/2591013 CrossRefGoogle Scholar
  31. Okur S, Dig D (2012) How do developers use parallel libraries?. In: Proceedings of the ACM SIGSOFT 20th international symposium on the foundations of software engineering (FSE). ACM, New York, pp 54:1–54:11.  https://doi.org/10.1145/2393596.2393660
  32. Okur S, Hartveld DL, Dig D, van Deursen A (2014) A study and toolkit for asynchronous programming in C#. In: Proceedings of the 36th international conference on software engineering (ICSE). ACM, New York, pp 1117–1127.  https://doi.org/10.1145/2568225.2568309
  33. Pankratius V, Schmidt F, Garretón G (2012) Combining functional and imperative programming for multicore software: an empirical study evaluating scala and java. In: Proceedings of the 34th international conference on software engineering (ICSE). IEEE Press, Piscataway, pp 123–133. http://dl.acm.org/citation.cfm?id=2337223.2337238
  34. Parnin C, Bird C, Murphy-Hill E (2011) Java generics adoption: how new features are introduced, championed, or ignored. In: Proceedings of the 8th working conference on mining software repositories (MSR). ACM, pp 3–12Google Scholar
  35. Parnin C, Bird C, Murphy-Hill E (2013) Adoption and use of java generics. Empir Softw Eng (EMSE) 18(6):1047–1089CrossRefGoogle Scholar
  36. Parr T (2013) The definitive ANTLR 4 reference, 2nd edn. The Pragmatic Programmers, RaleighGoogle Scholar
  37. Pinto G, Torres W, Fernandes B, Castor F, Barros RS (2015) A large-scale study on the usage of java’s concurrent programming constructs. J Syst Softw 106(Supplement C):59–81.  https://doi.org/10.1016/j.jss.2015.04.064. http://www.sciencedirect.com/science/article/pii/S0164121215000849 CrossRefGoogle Scholar
  38. Radoi C, Dig D (2013) Practical static race detection for java parallel loops. In: Proceedings of the 22nd international symposium on software testing and analysis (ISSTA). ACM, New York, pp 178–190.  https://doi.org/10.1145/2483760.2483765
  39. Stefik A, Hanenberg S (2014) The programming language wars: questions and responsibilities for the programming language community. In: Proceedings of the 13th ACM international symposium on new ideas, new paradigms, and reflections on programming & software (Onward!). ACM, pp 283–299Google Scholar
  40. Tempero E, Yang HY, Noble J (2013) What programmers do with inheritance in java. In: Castagna G (ed) Proceedings of the 27th European conference object-oriented programming (ECOOP). Springer Berlin Heidelberg, Berlin, Heidelberg, pp 577–601.  https://doi.org/10.1007/978-3-642-39038-8_24
  41. Torres W, Pinto G, Fernandes B, Oliveira JP, Ximenes FA, Castor F (2011) Are java programmers transitioning to multicore?: a large scale study of java FLOSS. In: Proceedings of the compilation of the co-located workshops on DSM’11, TMC’11, AGERE! 2011, AOOPES’11, NEAT’11, & VMIL’11. ACM, New York, pp 123–128.  https://doi.org/10.1145/2095050.2095072
  42. Tsantalis N, Mazinanian D, Rostami S (2017) Clone refactoring with lambda expressions. In: Proceedings of the 39th international conference on software engineering (ICSE). IEEE Press, Piscataway, pp 60–70.  https://doi.org/10.1109/ICSE.2017.14
  43. Uesbeck PM, Stefik A, Hanenberg S, Pedersen J, Daleiden P (2016) An empirical study on the Impact of C++ lambdas and programmer experience. In: Proceedings of the 38th international conference on software engineering (ICSE). ACM, pp 760–771Google Scholar
  44. Ukkonen E (1985) Algorithms for approximate String Matching. Inf Control 64 (1–3):100–118MathSciNetCrossRefzbMATHGoogle Scholar
  45. Wang X, Pollock L, Vijay-Shanker K (2017) Automatically generating natural language descriptions for object-related statement sequences. In: Proceedings of the 24th international conference on software analysis, evolution and reengineering (SANER). IEEE, pp 205–216Google Scholar
  46. Wu D, Chen L, Zhou Y, Xu B (2016) An extensive empirical study on C++ concurrency constructs. Inf Softw Technol 76(Supplement C):1–18.  https://doi.org/10.1016/j.infsof.2016.04.004. http://www.sciencedirect.com/science/article/pii/S0950584916300581 CrossRefGoogle Scholar

Copyright information

© Springer Science+Business Media, LLC, part of Springer Nature 2018

Authors and Affiliations

  • Sebastian Nielebock
    • 1
  • Robert Heumüller
    • 1
  • Frank Ortmeier
    • 1
  1. 1.Faculty of Computer Science, Chair of Software EngineeringOtto-von-Guericke-University MagdeburgMagdeburgGermany

Personalised recommendations