论文标题

输入还是不输入? GitHub上JavaScript和打字稿应用程序软件质量的系统比较

To Type or Not to Type? A Systematic Comparison of the Software Quality of JavaScript and TypeScript Applications on GitHub

论文作者

Bogner, Justus, Merkel, Manuel

论文摘要

JavaScript(JS)是最受欢迎的编程语言之一,广泛用于Web应用程序甚至后端开发。但是,由于其动态性质,JS应用程序通常以较差的软件质量而闻名。作为JavaScript的类型安全性超集,Typescript(TS)提供了解决此问题的功能。但是,目前没有足够的经验证据可以广泛支持TS应用程序比JS应用更好的软件质量的说法。 We therefore conducted a repository mining study based on 604 GitHub projects (299 for JS, 305 for TS) with over 16M LoC and collected four facets of software quality: a) code quality (# of code smells per LoC), b) code understandability (cognitive complexity per LoC), c) bug proneness (bug fix commit ratio), and d) bug resolution time (mean time a bug issue is open).对于TS,我们还收集了忽略使用“任何类型”的类型安全的频率。 分析表明,与JS应用相比,TS应用程序的代码质量和可理解性明显更好。然而,与期望相反,我们TS样本的错误置换和错误分辨率的时间不高于JS:平均错误修复提交比率大于60%以上(0.126 vs. 0.206),而TS项目平均需要一天以上的时间来修复错误(31.86 vs. 33.04天)。此外,除了bug pronentes(Spearman的Rho在0.17至0.26之间),减少TS应用中的任何类型的使用'类型的使用都与所有指标显着相关。 我们的结果表明,与JavaScript相比,Typescript对避免错误的积极影响可能比假设更为复杂。虽然使用TS似乎有好处,但它不会自动导致修复错误较少,更容易。但是,在这一领域需要进行更多的研究,尤其是关于项目复杂性和开发人员经验的潜在影响。

JavaScript (JS) is one of the most popular programming languages, and widely used for web apps and even backend development. Due to its dynamic nature, however, JS applications often have a reputation for poor software quality. As a type-safe superset of JavaScript, TypeScript (TS) offers features to address this. However, there is currently insufficient empirical evidence to broadly support the claim that TS apps exhibit better software quality than JS apps. We therefore conducted a repository mining study based on 604 GitHub projects (299 for JS, 305 for TS) with over 16M LoC and collected four facets of software quality: a) code quality (# of code smells per LoC), b) code understandability (cognitive complexity per LoC), c) bug proneness (bug fix commit ratio), and d) bug resolution time (mean time a bug issue is open). For TS, we also collected how frequently the type-safety ignoring `any` type was used. The analysis indicates that TS apps exhibit significantly better code quality and understandability than JS apps. Contrary to expectations, however, bug proneness and bug resolution time of our TS sample were not significantly lower than for JS: mean bug fix commit ratio was more than 60% larger (0.126 vs. 0.206), and TS projects needed on average more than an additional day to fix bugs (31.86 vs. 33.04 days). Furthermore, reducing the usage of the `any` type in TS apps was significantly correlated with all metrics except bug proneness (Spearman's rho between 0.17 and 0.26). Our results indicate that the perceived positive influence of TypeScript for avoiding bugs in comparison to JavaScript may be more complicated than assumed. While using TS seems to have benefits, it does not automatically lead to less and easier to fix bugs. However, more research is needed in this area, especially concerning the potential influence of project complexity and developer experience.

扫码加入交流群

加入微信交流群

微信交流群二维码

扫码加入学术交流群,获取更多资源