arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 1409.0252cs.SE
收藏

Rosetta代码中程序设计语言的比较研究

A Comparative Study of Programming Languages in Rosetta Code

Sebastian Nanz, Carlo A. Furia

摘要:

有时候,关于程序设计语言的争论与其说是科学的,不如说是宗教的。关于哪种语言更简洁、更高效,或者让开发人员更有效率的问题被热烈讨论,而他们的答案往往基于轶事和未经证实的信念。在这项研究中,我们使用Rosetta Code的基本未开发的研究潜力,这是一个各种语言常见编程任务解决方案的代码库,以得出一个公平和有根据的比较。Rosetta Code提供了一个用于分析的大型数据集。我们的研究基于7087个解决方案,对应于代表主要编程范式的8种广泛使用的语言中的745个任务(程序:C和Go;面向对象:C#和Java;功能:F#和Haskell;脚本:Python和Ruby)。我们的统计分析显示,最值得注意的是:函数式和脚本语言比过程式和面向对象语言更简洁;当涉及到大输入的原始速度时,C很难被击败,但在中等大小的输入上的性能差异不太明显,甚至允许解释语言具有竞争力;在编译时可以捕获更多缺陷的编译型强类型语言比解释型或弱类型语言更不容易出现运行时故障。我们讨论了这些结果对开发人员,语言设计人员和教育工作者的影响。

英文摘要:

Sometimes debates on programming languages are more religious than scientific. Questions about which language is more succinct or efficient, or makes developers more productive are discussed with fervor, and their answers are too often based on anecdotes and unsubstantiated beliefs. In this study, we use the largely untapped research potential of Rosetta Code, a code repository of solutions to common programming tasks in various languages, to draw a fair and well-founded comparison. Rosetta Code offers a large data set for analysis. Our study is based on 7087 solution programs corresponding to 745 tasks in 8 widely used languages representing the major programming paradigms (procedural: C and Go; object-oriented: C# and Java; functional: F# and Haskell; scripting: Python and Ruby). Our statistical analysis reveals, most notably, that: functional and scripting languages are more concise than procedural and object-oriented languages; C is hard to beat when it comes to raw speed on large inputs, but performance differences over inputs of moderate size are less pronounced and allow even interpreted languages to be competitive; compiled strongly-typed languages, where more defects can be caught at compile time, are less prone to runtime failures than interpreted or weakly-typed languages. We discuss implications of these results for developers, language designers, and educators.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑