Mining the use of higher-order functions:An exploratory study on Scala programs

被引:0
作者
Yisen Xu
Fan Wu
Xiangyang Jia
Lingbo Li
Jifeng Xuan
机构
[1] Wuhan University,School of Computer Science
[2] Turing Intelligence Technology Limited,undefined
来源
Empirical Software Engineering | 2020年 / 25卷
关键词
Scala programs; Higher-order functions; GitHub; Exploratory study; Correlation analysis; Code reuse;
D O I
暂无
中图分类号
学科分类号
摘要
A higher-order function takes one or more functions as inputs or outputs to support the generality of function definitions. In modern programming languages, higher-order functions are designed as a feature to enhance usability and scalability. Abstracting higher-order functions from existing functions decreases the number of similar functions and improves the code reuse. However, due to the complexity, defining and calling higher-order functions are not widely used in practice. In this paper, we investigate the use of higher-order functions in Scala programs. We collected 8,285 higher-order functions from 35 Scala projects in GitHub with the most stars and conducted an exploratory study via answering five research questions of using higher-order functions, including the data scale, the definition types, the definition distribution, the factor that correlates with the function calls, and the developer contribution. Our study mainly shows five empirical results about the common use of higher-order functions in Scala programs. Our findings are listed as follows. (1) Among 35 Scala projects, 6.84% of functions are defined as higher-order functions on average and the average calls per function show that higher-order functions are called more frequently than first-order functions. (2) In all higher-order functions in the study, 87.35% of definitions of higher-order functions and 90.66% of calls belong to the type that only takes functions as parameters. (3) Three measurements (including lines of executable code, Cyclomatic complexity, and warnings in the code style) in higher-order functions are lower than those of first-order functions. (4) Regression analysis on all projects suggests that the number of calling higher-order functions highly correlates with the Cyclomatic complexity. (5) In all projects in the study, 43.82% calls of higher-order functions are written by the same developers who have defined the functions and results show that top 20% authors of higher-order functions favor defining or calling higher-order functions than first-order functions. This study can be viewed as a preliminary result to understand the use of higher-order functions and to motivate further investigation in Scala programs.
引用
收藏
页码:4547 / 4584
页数:37
相关论文
共 35 条
[1]  
Albrecht AJJr(1983)Software function, source lines of code, and development effort prediction: A software science validation IEEE Trans Softw Eng 9 639-648
[2]  
Gaffney JE(2007)Confounder selection in environmental epidemiology: Assessment of health effects of prenatal mercury exposure Ann Epidemiol 17 27-35
[3]  
Budtz-Jorgensen E(1985)On understanding types, data abstraction, and polymorphism ACM Comput Surv 17 471-522
[4]  
Keiding N(2019)Does the fault reside in a stack trace? assisting crash localization by predicting crashing fault residence J Syst Softw 148 88-104
[5]  
Grandjean P(1976)A complexity measure IEEE Trans Softw Eng 2 308-320
[6]  
Weihe P(2016)An empirical study of the impact of modern code review practices on software quality Empir Softw Eng 21 2146-2189
[7]  
Cardelli L(2001)The pareto, zipf and other power laws Econ Lett 74 15-19
[8]  
Wegner P(2018)Synthesizable higher-order functions for C++ IEEE Trans CAD Integr Circ Syst 37 2835-2844
[9]  
Gu Y(2017)Executing and verifying higher-order functional-imperative programs in maude J Log Algebr Meth Program 93 68-91
[10]  
Xuan J(2018)Test generation for higher-order functions in dynamic languages PACMPL 2 161:1-161:27