Suppr超能文献

对Rust代码冗长性、可理解性和复杂性的评估。

Evaluation of Rust code verbosity, understandability and complexity.

作者信息

Ardito Luca, Barbato Luca, Coppola Riccardo, Valsesia Michele

机构信息

Department of Control and Computer Engineering, Polytechnic Institute of Turin, Torino, Piemonte, Italia.

Luminem, Torino, Piemonte, Italia.

出版信息

PeerJ Comput Sci. 2021 Feb 26;7:e406. doi: 10.7717/peerj-cs.406. eCollection 2021.

Abstract

Rust is an innovative programming language initially implemented by Mozilla, developed to ensure high performance, reliability, and productivity. The final purpose of this study consists of applying a set of common static software metrics to programs written in Rust to assess the verbosity, understandability, organization, complexity, and maintainability of the language. To that extent, nine different implementations of algorithms available in different languages were selected. We computed a set of metrics for Rust, comparing them with the ones obtained from C and a set of object-oriented languages: C++, Python, JavaScript, TypeScript. To parse the software artifacts and compute the metrics, it was leveraged a tool called that was extended with a software module, written in Python, with the aim of uniforming and comparing the results. The Rust code had an average verbosity in terms of the raw size of the code. It exposed the most structured source organization in terms of the number of methods. Rust code had a better Cyclomatic Complexity, Halstead Metrics, and Maintainability Indexes than C and C++ but performed worse than the other considered object-oriented languages. Lastly, the Rust code exhibited the lowest COGNITIVE complexity of all languages. The collected measures prove that the Rust language has average complexity and maintainability compared to a set of popular languages. It is more easily maintainable and less complex than the C and C++ languages, which can be considered syntactically similar. These results, paired with the memory safety and safe concurrency characteristics of the language, can encourage wider adoption of the language of Rust in substitution of the C language in both the open-source and industrial environments.

摘要

Rust是一种最初由Mozilla实现的创新型编程语言,其开发目的是确保高性能、可靠性和生产力。本研究的最终目的是将一组常见的静态软件指标应用于用Rust编写的程序,以评估该语言的冗长性、可理解性、组织性、复杂性和可维护性。为此,选择了不同语言中可用的九种不同算法实现。我们为Rust计算了一组指标,并将它们与从C以及一组面向对象语言(C++、Python、JavaScript、TypeScript)获得的指标进行比较。为了解析软件工件并计算指标,我们利用了一个名为 的工具,该工具通过一个用Python编写的软件模块进行了扩展,目的是统一和比较结果。就代码的原始大小而言,Rust代码的冗长性平均。就方法数量而言,它展现出最结构化的源组织。Rust代码的圈复杂度、哈尔斯特德度量和可维护性指数比C和C++更好,但比其他考虑的面向对象语言表现更差。最后,Rust代码在所有语言中展现出最低的认知复杂度。收集到的度量结果证明,与一组流行语言相比,Rust语言具有平均的复杂度和可维护性。它比C和C++语言更易于维护且复杂度更低,C和C++在语法上可被认为是相似的。这些结果,再加上该语言的内存安全性和安全并发特性,可以鼓励在开源和工业环境中更广泛地采用Rust语言来替代C语言。

https://cdn.ncbi.nlm.nih.gov/pmc/blobs/10cc/7959618/b3f3872170db/peerj-cs-07-406-g001.jpg

文献检索

告别复杂PubMed语法,用中文像聊天一样搜索,搜遍4000万医学文献。AI智能推荐,让科研检索更轻松。

立即免费搜索

文件翻译

保留排版,准确专业,支持PDF/Word/PPT等文件格式,支持 12+语言互译。

免费翻译文档

深度研究

AI帮你快速写综述,25分钟生成高质量综述,智能提取关键信息,辅助科研写作。

立即免费体验