论文标题
关于在JavaScript项目中受功能编程启发的结构的漏洞主持性
On the Bug-proneness of Structures Inspired by Functional Programming in JavaScript Projects
论文作者
论文摘要
受功能编程启发的语言结构已进入大多数主流编程语言。许多研究人员和开发人员认为,这些结构会导致更简洁,可重复使用且易于理解的程序。但是,很少有研究研究在主流编程语言中使用它们的含义。本文量化了通常与JavaScript中功能编程相关的四个概念的流行率:递归,不变性,懒惰评估和功能作为值。由于其成立以来,该语言中的某些概念,功能编程语言的灵感及其受欢迎程度,我们专注于JavaScript程序。我们挖掘了91个GitHub存储库(22多个LOC)主要用JavaScript(超过50%的代码)写,从静态和时间的角度来测量这些概念的用法。我们还衡量了将漏洞固定的可能性删除这些概念的用途(这暗示了漏洞 - 主持性)及其与存在代码注释的关联(这暗示代码很难理解)。我们发现这些概念在广泛使用中(每46.65个LOC,43.59%的LOC)。此外,多年来,在经过分析的项目中,高阶功能,不变性和与评估相关的结构的使用一直在增长,而递归和回调和诺言的使用也有所下降。我们还发现统计证据表明,除了与不变性相关的结构以外,在固定犯罪中,除了与其他提交相关。此外,它们的存在与评论大小无关。我们的发现表明,功能编程概念对于使用多范式语言的开发人员很重要,并且它们的用法并不能使程序更难理解。
Language constructs inspired by functional programming have made their way into most mainstream programming languages. Many researchers and developers consider that these constructs lead to programs that are more concise, reusable, and easier to understand. However, few studies investigate the implications of using them in mainstream programming languages. This paper quantifies the prevalence of four concepts typically associated with functional programming in JavaScript: recursion, immutability, lazy evaluation, and functions as values. We focus on JavaScript programs due to the availability of some of these concepts in the language since its inception, its inspiration from functional programming languages, and its popularity. We mine 91 GitHub repositories (22+ million LOC) written mostly in JavaScript (over 50% of the code), measuring the usage of these concepts from both static and temporal perspectives. We also measure the likelihood of bug-fixing commits removing uses of these concepts (which would hint at bug-proneness) and their association with the presence of code comments (which would hint at code that is hard to understand). We find that these concepts are in widespread use (1 for every 46.65 LOC, 43.59% of LOC). In addition, the usage of higher-order functions, immutability, and lazy evaluation-related structures has been growing throughout the years for the analyzed projects, while the usage of recursion and callbacks & promises has decreased. We also find statistical evidence that removing these structures, with the exception of the ones associated to immutability, is less common in bug-fixing commits than in other commits. In addition, their presence is not correlated with comment size. Our findings suggest that functional programming concepts are important for developers using a multi-paradigm language, and their usage does not make programs harder to understand.