Quine, RIP

By anders pearson 23 Feb 2001

i missed this, but Willard van Orman Quine is dead [NYTimes article, use ‘cipherpunk’ as username and password]. Quine, along with Alfred North Whitehead, Bertrand Russell, Alan Turing, Stephen Kleene, and Alonzo Church basically invented the fields of logic, the lambda calculus (which follows from logic), and programming (which follows from the lambda calculus).

“Quine” is defined in the Jargon File as:

quine /kwi:n/ n.

[from the name of the logician Willard van Orman Quine, via Douglas Hofstadter] A program that generates a copy of its own source text as its complete output. Devising the shortest possible quine in some given programming language is a common hackish amusement. (We ignore some variants of BASIC in which a program consisting of a single empty string literal reproduces itself trivially.) Here is one classic quine:

((lambda (x)
(list x (list (quote quote) x)))
(quote
(lambda (x)
(list x (list (quote quote) x)))))


This one works in LISP or Scheme. It’s relatively easy to write quines in other languages such as Postscript which readily handle programs as data; much harder (and thus more challenging!) in languages like C which do not. Here is a classic C quine for ASCII machines:

char*f=“char*f=%c%s%c;main()
{printf(f,34,f,34,10);}%c”;
main(){printf(f,34,f,34,10);}


For excruciatingly exact quinishness, remove the interior line breaks. Here is another elegant quine in ANSI C:

#define q(k)main(){return!puts(#k”\nq(“#k”)”);}
q(#define q(k)main(){return!puts(#k”\nq(“#k”)”);})


Some infamous Obfuscated C Contest entries have been quines that reproduced in exotic ways.

there’s also a nice page listing quines in almost every language. basically, the field of computer science owes a lot to this man and he will be greatly missed.