For faster navigation, this Iframe is preloading the Wikiwand page for 格林斯潘第十定律.

格林斯潘第十定律

格林斯潘第十定律(Greenspun's tenth rule)是计算机编程领域,尤其是编程语言领域的一句格言[1][2]

任何CFortran程序复杂到一定程度之后,都会包含一个临时开发的、不合规范的、充满程序错误的、运行速度很慢的、只有一半功能的Common Lisp实现。

这表现了Lisp语言的灵活性和可扩展性,它包含了理论上编写复杂计算机程序需要的所有功能。而其他编程语言的核心实现却不能提供开发复杂程序的关键性功能支持。

来源

[编辑]

该定律由菲利普·格林斯潘(Philip Greenspun)于1993年前后提出。尽管被称作“第十定律”,然而实际上并没有前九个定律。格林斯潘曾解释说:

对不起,Han-Wen,前面并没有九个定律。我只是想给它取一个令人印象深刻的名字。[3]

含义

[编辑]

Lisp语法几乎是抽象的,其程序以S-表达式形式构建,这等价于其他编程语言内置编译器中的抽象语法树。Lisp作为一种同像(homoiconic)的语言,不区分代码与数据,即:Lisp程序本身即Lisp数据结构。Lisp程序自身可通过生成额外的Lisp程序。因此,程序员可以相对轻松地构建复杂的特定领域语言。

如同保罗·格雷厄姆所说,Lisp比起其他语言可以更快地构建更健壮的程序。[4]特别是Common Lisp有相当大的标准库,其中有大量的功能和灵活的接口,能写出符合各种编程范式的程序(如removereducemap等)。格林斯潘第十定律表示,任何复杂软件系统都需要上述的功能,都将从头到尾重新设计开发这一套系统,而这在Common Lisp中已经存在了。

莫里斯推论

[编辑]

知名黑客罗伯特·泰潘·莫里斯后来给该定律加上了推论,澄清适用该定律的“足够复杂的”程序集合:

……包括Common Lisp。[5]

可以认为是对编写庞大而复杂的Common Lisp程序困难性的评论,或仅仅是对于Lisp中eval函数的幽默。格林斯潘第十定律和莫里斯推论都具备黑客幽默中“哈哈,但的确如此”的风格特征。[6]

参见

[编辑]

参考

[编辑]
  1. ^ Philip Greenspun's Research. [2012-05-21]. (原始内容存档于2009-01-24). 
  2. ^ Paul Graham. Revenge of the Nerds. 2002-05. (原始内容存档于2019-06-07). 
  3. ^ Philip Greenspun. 10th rule of programming. 2003-11-27. (原始内容存档于2022-01-25). 
  4. ^ Paul Graham. Beating the Averages. 2003-04. (原始内容存档于2022-01-29). 
  5. ^ Paul Graham. Lisp Quotes. [2022-02-02]. (原始内容存档于2023-04-20). 
  6. ^ Jargon File entry on "ha ha only serious". [2012-05-21]. (原始内容存档于2021-02-27). 
{{bottomLinkPreText}} {{bottomLinkText}}
格林斯潘第十定律
Listen to this article

This browser is not supported by Wikiwand :(
Wikiwand requires a browser with modern capabilities in order to provide you with the best reading experience.
Please download and use one of the following browsers:

This article was just edited, click to reload
This article has been deleted on Wikipedia (Why?)

Back to homepage

Please click Add in the dialog above
Please click Allow in the top-left corner,
then click Install Now in the dialog
Please click Open in the download dialog,
then click Install
Please click the "Downloads" icon in the Safari toolbar, open the first download in the list,
then click Install
{{::$root.activation.text}}

Install Wikiwand

Install on Chrome Install on Firefox
Don't forget to rate us

Tell your friends about Wikiwand!

Gmail Facebook Twitter Link

Enjoying Wikiwand?

Tell your friends and spread the love:
Share on Gmail Share on Facebook Share on Twitter Share on Buffer

Our magic isn't perfect

You can help our automatic cover photo selection by reporting an unsuitable photo.

This photo is visually disturbing This photo is not a good choice

Thank you for helping!


Your input will affect cover photo selection, along with input from other users.

X

Get ready for Wikiwand 2.0 🎉! the new version arrives on September 1st! Don't want to wait?