A Study on the Pythonic Functional Constructs' Understandability
Cyrine Zid, Fiorella Zampetti, Giuliano Antoniol, Massimiliano Di Penta
Abstract
The use of functional constructs in programming languages such as Python has been advocated to help write more concise source code, improve parallelization, and reduce side effects. Nevertheless, their usage could lead to understandability issues. This paper reports the results of a controlled experiment conducted with 209 developers to assess the understandability of given Pythonic functional constructs---namely lambdas, comprehensions, and map/reduce/-filter functions---if compared to their procedural alternatives. To address the study's goal, we asked developers to modify code using functional constructs or not, to compare the understandability of different implementations, and to provide insights about when and where it is preferable to use such functional constructs. Results of the study indicate that code snippets with lambdas are more straightforward to modify than the procedural alternatives. However, this is not the case for comprehension. Regarding the perceived understandability, code snippets relying on procedural implementations are considered more readable than their functional alternatives. Last but not least, while functional constructs may help write compact code, improving maintainability and performance, they are considered hard to debug. Our results can lead to better education in using functional constructs, prioritizing quality assurance activities, and enhancing tool support for developers.
Ask about this paper
Your agent reads all of it.
Lune indexed this paper to the last equation, along with the top-tier papers that cite it. Ask a question and the answer quotes them.
Builds on4
- Making Python code idiomatic by automatic refactoring non-idiomatic Python code with pythonic idiomsZejun Zhang, Zhenchang Xing, Xin Xia, Xiwei Xu et al.FSE 2022 · 35 citations
- Faster or Slower? Performance Mystery of Python Idioms Unveiled with Empirical EvidenceZejun Zhang, Zhenchang Xing, Xin Xia, Xiwei Xu et al.ICSE 2023 · 16 citations
- Why Do Developers Remove Lambda Expressions in Java?Mingwei Zheng, Jun Yang, Ming Wen, Hengcheng Zhu et al.ASE 2021 · 9 citations
- An exploratory study on the predominant programming paradigms in Python codeRobert Dyer, Jigyasa ChauhanFSE 2022 · 6 citations
Related papers
- Hard to Read and Understand Pythonic Idioms? DeIdiom and Explain Them in Non-Idiomatic Equivalent CodeZejun Zhang, Zhenchang Xing, Dehai Zhao, Qinghua Lu et al.ICSE 2024 · 7 citations
- Imperative versus Declarative Collection Processing: An RCT on the Understandability of Traditional Loops versus the Stream API in JavaNils Mehlhorn, Stefan HanenbergICSE 2022 · 4 citations
- Does the Stream API Benefit from Special Debugging Facilities? A Controlled Experiment on Loops and Streams with Specific DebuggersJan Reichl, Stefan Hanenberg, Volker GruhnICSE 2023 · 1 citation
- On the Relationship between Code Verifiability and UnderstandabilityKobi Feldman, Martin Kellogg, Oscar ChaparroFSE 2023 · 2 citations
- Convergent Representations of Computer Programs in Human and Artificial Neural NetworksShashank Srikant, Ben Lipkin, Anna A. Ivanova, Evelina Fedorenko et al.NeurIPS 2022 · 16 citations
