编译商(CQ):一种衡量编程语言编译难度的度量
Compilation Quotient (CQ): A Metric for the Compilation Hardness of Programming Languages
AI总结:
本文提出编译商(CQ)度量,通过从上下文无关文法采样超1200万程序并测编译成功率,量化12种编译语言的编译难度,发现C语言CQ为48.11而Rust近0,有助于理解语言差异并辅助设计。
摘要:
如今的程序员可以从种类繁多的编程语言中进行选择,每种语言都有其自身的特点、用途和复杂性。语言复杂性的一个关键方面是用该语言编译程序的难度。虽然大多数程序员对不同编程语言的编译难度有直观感受,但尚无度量标准来量化它。我们引入了编译商(CQ),一种用于量化编译型编程语言编译难度的度量。其核心思想是测量从上下文无关文法中采样的程序的编译成功率。为此,我们公平地采样了总计超过1200万个程序。CQ的取值范围在0到100之间,其中0表示没有程序能编译成功,100表示所有程序都能编译成功。我们对12种流行的编译型编程语言的研究结果显示,CQ存在很大差异。C语言的CQ为48.11,C++为0.60,Java为0.27,Haskell为0.13。令人惊讶的是,Rust的CQ几乎为0,而对于C语言,即使是非常大型的程序也有很大比例能够编译成功。我们相信CQ有助于更好地理解编译型编程语言之间的差异,并能为语言设计者提供帮助。
英文摘要:
Today's programmers can choose from an exceptional range of programming languages, each with its own traits, purpose, and complexity. A key aspect of a language's complexity is how hard it is to compile programs in the language. While most programmers have an intuition about compilation hardness for different programming languages, no metric exists to quantify it. We introduce the compilation quotient (CQ), a metric to quantify the compilation hardness of compiled programming languages. The key idea is to measure the compilation success rates of programs sampled from context-free grammars. To this end, we fairly sample over 12 million programs in total. CQ ranges between 0 and 100, where 0 indicates that no programs compile, and 100 means that all programs compile. Our findings on 12 popular compiled programming languages show high variation in CQ. C has a CQ of 48.11, C++ has 0.60, Java has 0.27 and Haskell has 0.13. Strikingly, Rust's CQ is nearly 0, and for C, even a large fraction of very sizable programs compile. We believe CQ can help understand the differences of compiled programming languages better and help language designers.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。