|News||Back to basics||Recommended Books||Recommended Links||The Second System Effect||Parkinson Law||Unix Component Model|
|Conceptual Integrity||Brooks law||Conway Law||Featuritis||Premature Optimization is the root of all evil||The Second System Effect|
|Cargo cult programming||Real Insights into Architecture Come Only From Actual Programming||Program Understanding||Software Prototyping||Programming as a Profession||Project Management|
|Pipes||Scripting||Open Source and Bloatware||History||Humor||Software engineering quotes||Etc|
Greenspun's tenth rule of programming is an aphorism in computer programming and especially programming language circles that states:
Any sufficiently complicated C or Fortran program contains an ad hoc, informally-specified, bug-ridden, slow implementation of half of Common Lisp.
This expresses the opinion that the perceived flexibility and extensibility designed into the Lisp programming language includes all functionality that is theoretically necessary to write a complex computer program, and that the core implementations of other programming languages often do not supply critical functionality necessary to develop complex programs.
The rule was written sometime around 1993 by Philip Greenspun. Although it is known as his tenth rule, there are in fact no preceding rules, only the tenth. The reason for this according to Greenspun:
Sorry, Han-Wen, but there aren't 9 preceding laws. I was just trying to give the rule a memorable name.  MeaningLisp syntax is barely abstract; Lisp programs are constructed as trees of S-expressions, which are equivalent to the abstract syntax trees that compilers of other languages create internally. As a homoiconic language, Lisp also makes no distinction between code and data; Lisp programs are themselves just Lisp data structures. Lisp programs can thus generate additional Lisp programs themselves via macros. As a result, the programmer can construct complex domain specific languages with relative ease. Lisp advocates such as Paul Graham claim that this allows faster construction of more robust software compared to other languages. Common Lisp, specifically, has quite large standard library with large number of functions with flexible interfaces, that capture many programming paradigms (like remove, reduce, map, etc.).
Greenspun's Rule expresses the opinion that these capabilities are necessary for any complex software package, and so will be redesigned from scratch in an ad hoc manner in any large project, duplicating effort already exerted in Common Lisp.
Well-known hacker Robert Morris later enounced a corollary which clarifies the set of "sufficiently complicated" programs to which the rule applies:
…including Common Lisp.
This can be viewed as a commentary on the difficulty of creating an efficient implementation of the large and complex Common Lisp language, or simply a joke about Lisp's eval function. Both Greenspun's rule and Morris's corollary are examples of a characteristic style of hacker humor known as "ha ha only serious".
I cut this:
This is incorrect. It is based on a misinterpretation of Philip's Rule. Philip's Rule neither requires a scripting language, nor are most scripting language functional. I'll give an analogy: In much the same way as GTK implements object oriented programming on top of C, most complex system eventually implement some subset of functional programming language on top of C. This isn't necessarily externally visible. It might be some dude hacking on a calculator program, and finds he wants the user to be able to compose expresions: f(x)=g(h(x)), so implements a data structure of a linked list of function pointers, emulating closures, poorly. Another guy implements reference counting by overriding operators in C++, to make memory management easier for some type of object. As systems get more complex, these hacks get more complex, and eventually you end up with half of Lisp/Scheme/... in the program, only implemented badly.
126.96.36.199 22:00, 21 October 2007 (UTC)
FFI and MOP are missing from the standard, too.
I think the article needs a complete overhaul. It should take into account that a lot has happened since the Common Lisp language standard came out. It should explain, too, that big ("diagonal") languages are also needed and that you need experience implementing them - the niche (once) filled by Common Lisp. --Anon.
That sounds like anti-Lisp bias to me. At the very least, that account doesn't represent a gaping hole, so I'm going to take the cleanup off at this point and I suggest Anon tag this as unbalanced if they feel their view is neutral. Vagary 20:20, 11 August 2006 (UTC)
"You can certainly edit the wikipedia if you like, though I'm not sure it is that interesting. I just thought it sounded better to have a 10th rule, as though it were part of a comprehensive system."
Is an email I recieved from Greenspun, how would I put that up for citation? I have the full email in my GMail account.
I recently added to Common Lisp a quote by Paul Graham in which he says that Yahoo's rewrite of Yahoo Store is a perfect example of this rule. Should this be added to the article? --maru (talk) contribs 20:54, 21 August 2006 (UTC)
I've requested cites on a few things to ensure the article doesn't start looking like original research here... Greenspun's quote (which someone said they had a source for), the "ha ha only serious" statement, and the generalization. If I Google for the text of the claimed generalization, I don't see any obvious reliable sources to source it to, so it's in question... --Ds13 (talk) 20:41, 18 April 2008 (UTC)
I have the opposite question myself. The only place I've ever seen the phrase "ha ha only serious" is in the jargon file. I wonder if that phrase is actually in common use, and I also wonder if there's really anything unique about "hackers" in this respect -- programmer's are hardly the inventors of "truth in jest". -- Doom (talk) 04:31, 22 November 2008 (UTC)
I am tempted to add to the Prolog follow-up section the example of Paradigms of Artificial Intelligence Programming, where all the code examples in the book are in Lisp, until such time that the author, Peter Norvig, describes a Prolog interpreter, after which time all code examples are in Prolog. Atannir (talk) 17:29, 28 January 2009 (UTC)
Honestly, I understand the aphorism well, as I code in scheme, layered on top of a C++ structure that is prolog-like. And would like to have erlang or scala (programming language)-like features. What language *should* I code in? Does this language exist? linas (talk) 17:08, 1 September 2009 (UTC)
Any sufficiently complicated NoSQL program contains an ad hoc, informally-specified, bug-ridden,slow implementation of half of SQL
The referenced email for the quote regarding erlang doesn't seem related to the article, and doesn't contain the quote in question. This  message contains the quote, with attribution to Robert Virdig, although a follow-up indicates a prior usage (with broken link). There are a couple of quotes of this:  and  attributing it to Virdig. 188.8.131.52 (talk) 19:53, 25 March 2011 (UTC)
Common Lisp is not a functional language (given the examples, the intent was clearly to talk about purely functional languages) and also Greenspun's Tenth Rule is not limited to functional language features of Lisp, so the pretended Generalization makes no sense, which matches with the fact that nobody seems to ever had heard it before. Instead of merely suggesting to remove it, I'm doing it right now because i fear mere suggestion will lead nowhere in any reasonable timeframe. If somebody thinks i'm wrong in my analysis, restore it and explain why here. --184.108.40.206 (talk) 23:50, 6 August 2011 (UTC)
The "Meaning" section is completly off the mark; it for some reason starts off talking about Lisp syntax and macros... whereas any recovering C++/Fortran vetran can tell you that the beef is in the features common with today's popular dynamic languages including automatic memory management, high level data structures and strong typing.
Greenspun 10th law of programming
c - Greenspun's Tenth Rule, does every large project include a Lisp interpreter - Programmers
c++ - Does every large project include a Lisp …
Greenspun's Tenth Rule- 9786201337916- Amazon.com- Books
Philip Greenspun's Research
Obtaining GSview 5.0