Example Of Greenspuns Tenth At Work

Here is an example of GreenspunsTenthRuleOfProgramming at work:

Microsoft have a "variant types" ApplicationProgrammingInterface, implemented in C, that emulates the kind of DynamicTyping found natively in CommonLisp. It's poorly optimized, slow, and inconvenient to work with. Their MAPI interface contains another reinvention of dynamic typing, incompatible with this one.

  typedef unsigned short VARTYPE;

enum VARENUM{ VT_EMPTY = 0, // Not specified VT_NULL = 1, // NULL VT_I2 = 2,// 2-byte signed int VT_I4 = 3,// 4-byte signed int VT_R4 = 4,// 4-byte real VT_R8 = 5,// 8-byte real VT_CY = 6,// Currency VT_DATE = 7, // Date VT_BSTR = 8, // Binary string VT_DISPATCH = 9, // IDispatch FAR* VT_ERROR = 10, // Scodes VT_BOOL = 11, // Boolean; True=-1, False=0 VT_VARIANT = 12, // VARIANT FAR* VT_UNKNOWN = 13, // IUnknown FAR* VT_UI1 = 17, // Unsigned char

typedef struct tagVARIANT { VARTYPE vt; unsigned short wReserved1; unsigned short wReserved2; unsigned short wReserved3; union { unsigned char bVal; short iVal; long lVal; float fltVal;. double dblVal; VARIANT_BOOL boolVal; SCODE scode; CY cyVal; DATE date ; BSTR bstrVal; IUnknown FAR* punkVal; IDispatch FAR* pdispVal; SAFEARRAY FAR* parray; unsigned char FAR* pbVal; short FAR* piVal; long FAR* plVal; float FAR* pfltVal; double FAR* pdblVal; VARIANT_BOOL FAR* pboolVal; SCODE FAR* pscode; CY FAR* pcyVal; DATE FAR* pdate; BSTR FAR* pbstrVal ; IUnknown FAR* FAR* ppunkVal ; IDispatch FAR* FAR*ppdispVal ; SAFEARRAY FAR* FAR* pparray ; VARIANT FAR* pvarVal; void FAR* byref;};};


I disagree that this is actually an example of GreenspunsTenthRuleOfProgramming; to quote the above:

Microsoft have a "variant types" ApplicationProgrammingInterface, implemented in C, that emulates the kind of DynamicTyping found natively in CommonLisp.

And many other languages, eg Smalltalk, Java, Python, Mathematica, ... C is kind of a loner with its lowly string ability.

It's poorly optimized no it isn't, slow no it isn't, and inconvenient to work with the arrays are a mess but are easily encapsulated.

Their MAPI interface contains another reinvention of dynamic typing, incompatible with this one.

More details, please? This page is so inaccurate in other respects that I am not sure how much credence to give that assertion.

Anyway, what does this have to do with Lisp? Feh. I've seen plenty of examples of Greenspun's Rule, but this is not a good one. AntiMicrosoftBiasOnWiki is doubly sad if the criticism doesn't even make sense.


By far the best example I know of is the reimplementation of Yahoo! Stores in C++. As the shop builder evals Lisp code, they would have essentially had to implement a Lisp interpreter in C++. Ack! -- NoelWelsh

Does anyone know why this (in)famous re-implementation was done? And does anyone know the official reason?

I can't say for sure, but I thought I read that it was because the pointy haired bosses wanted it written in a standard language, i.e. something they'd heard of. Stupid as hell if you ask me, they paid like 90million bucks just to essentially downgrade it, not realizing that Lisp is the reason it was so good.

There's an anecdote about a Common Lisp programmer interviewing at Yahoo!, mentioning he'd like to work on Yahoo! Stores. The boss says that they're planning on reimplementing it in C++. Why? They can't find Common Lisp programmers.


The Ant build tool is an example of GreenspunsTenthRuleOfProgramming. It has an XML syntax and an excruciatingly awkward way of using variables, writing conditional logic and calling tasks.

Ant is a _build tool_ (more precisely, as a better make). Majority of users consider serious programming/scripting in Ant an abomination. Anyway, how is having an XML syntax and awkward control constructs like implementing half of Lisp? If it is, then Excel and DOS batch files are also greenspunning.

Build tools are an example of an ExpertSystem?--a build tool which contains a language (especially one which is TuringComplete) strikes me as a DomainSpecificLanguage). DSL's, IMHO, ought to be exempted from charges of GreenSpunning.

Besides - how about MakeTool itself (in particular, GnuMake and anything which acts like it)? It's got a TuringComplete language - one which is essentially a primitive Lisp dialect that puts dollar signs in front of its parentheses.

I think some corollary to Greenspuns 10th is in order for GNU Make in its reimplementation of Prolog... And while backward chaining is ok for chasing dependencies, forward chaining (ala CLIPS, another language with sexp syntax) is probably better for describing the actions of a build system ("when a .y file is entered, make a .c file, when a .c file is entered, make a .o file, when these .c files enter, make this lib"). Sorry, Common lisp doesn't do *everything*, and just because CLIPS and Algernon use sexps doesn't mean CL has any claim on them.

Greenspunning is something which is done by programmers, not by languages. C++ doesn't engage in greenspunning, C++ programmers do. (Sometimes. OK, often). The amount of greenspunning a language might require could be considered a figure of merit; but to say that a particular tool designed for a specific purpose is GreenSpunning when it carries out that purpose is silly.


This might make the lisp lot gasp in horror but it might be of interest. We once started writing a numeric evaluator in java when we needed an expression parser to evaluate formulae in a basic framework environment - after a couple of days I decided just to use a database connector and submit select statements to the server. This meant we could do string manipulation as well of course in addition to homogeneously looking up currency rates etc...


See also: LispShowOffExamples


EditText of this page (last edited September 1, 2005) or FindPage with title or text search