FACTOID # 130: In Belgium, 55% of government ministers are female. The country’s first female parliamentarian was appointed in 1921.
 
 Home   Encyclopedia   Statistics   Countries A-Z   Flags   Maps   Education   Forum   FAQ   About 
 
WHAT'S NEW
RELATED ARTICLES
People who viewed "Quine" also viewed:
RECENT ARTICLES
More Recent Articles »
 

SEARCH ALL

FACTS & STATISTICS    Advanced view

Search encyclopedia, statistics and forums:

 

 

(* = Graphable)

 

 


Encyclopedia > Quine

In computing, a quine is a program (a form of metaprogram) that produces its complete source code as its only output. For amusement, hackers sometimes attempt to develop the shortest possible quine in any given programming language. Originally, the word computing was synonymous with counting and calculating, and a science that deals with the original sense of computing mathematical calculations. ... A computer program or software program (usually abbreviated to a program) is a step-by-step list of instructions written for a particular computer architecture in a particular computer programming language. ... Metaprogramming is the writing of programs that write or manipulate other programs (or themselves) as their data or that do part of the work that is otherwise done at runtime during compile time. ... Source code (commonly just source or code) is any series of statements written in some human-readable computer programming language. ... For other uses, see Hacker (disambiguation). ... Computer code (HTML with JavaScript) in a tool that uses syntax highlighting (colors) to help the developer see the purpose of each piece of code. ...


Note that programs which take input are not considered quines. This would allow the source code to be fed to the program via keyboard input, opening the source file of the program, and similar mechanisms. Also, a quine which contains no code is ruled out as trivial; in many programming languages executing such a program will output the code (i.e. nothing). Such an empty program once won the "worst abuse of the rules" prize in the Obfuscated C contest (indeed, an empty program is not legal ISO C since it has no main() function, so many compilers will reject it). The International Obfuscated C Code Contest (abbr. ... ANSI C (Standard C) is a variant of the C programming language. ...


Quines are named after philosopher Willard Van Orman Quine (1908–2000), who made an extensive study of indirect self-reference: he coined, among others, the paradox-producing expression, "yields falsehood when appended to its own quotation." W.V. Quine Willard Van Orman Quine (June 25, 1908 – December 25, 2000), usually cited as W.V. Quine or W.V.O. Quine but known to his friends as Van, was one of the most influential American philosophers and logicians of the 20th century. ... Indirect self-reference describes an object referring to itself indirectly. ...

Contents


History

A quine exists in any programming language with the ability to output any computable string, as a direct consequence of Kleene's recursion theorem. The specific idea of quines first appeared in Bratley, Paul and Jean Millo. "Computer Recreations; Self-Reproducing Automata", Software -- Practice & Experience, Vol. 2 (1972). pp. 397-400. Bratley first became interested in self-reproducing programs after seeing the first known such program written in Atlas Autocode at Edinburgh in the 1960s by the University of Edinburgh lecturer and researcher Hamish Dewar. This program appears below: Kleenes recursion theorem is a result in computability theory first proved by Stephen Kleene; it allows to construct programs, Turing machines and recursive functions that refer back to their own description. ... Atlas Autocode (AA) was a programming language developed at Manchester University for the Atlas Computer. ... The University of Edinburgh, founded in 1583, is a renowned centre for teaching and research in Edinburgh, Scotland. ...

 %BEGIN !THIS IS A SELF-REPRODUCING PROGRAM %ROUTINESPEC R R PRINT SYMBOL(39) R PRINT SYMBOL(39) NEWLINE %CAPTION %END~ %CAPTION %ENDOFPROGRAM~ %ROUTINE R %PRINTTEXT ' %BEGIN !THIS IS A SELF-REPRODUCING PROGRAM %ROUTINESPEC R R PRINT SYMBOL(39) R PRINT SYMBOL(39) NEWLINE %CAPTION %END~ %CAPTION %ENDOFPROGRAM~ %ROUTINE R %PRINTTEXT ' %END %ENDOFPROGRAM 

Examples

For more examples, see Wikisource:Quines

C
 /* A simple quine (self-printing program), in standard C. */ /* Note: in designing this quine, we have tried to make the code clear * and readable, not concise and obscure as many quines are, so that * the general principle can be made clear at the expense of length. * In a nutshell: use the same data structure (called "progdata" * below) to output the program code (which it represents) and its own * textual representation. */ #include <stdio.h> void quote(const char *s) /* This function takes a character string s and prints the * textual representation of s as it might appear formatted in C * code. */ { int i; printf(" ""); for (i = 0; s[i]; i++) { /* Certain characters are quoted. */ if (s[i] == '') printf(""); else if (s[i] == '"') printf("""); else if (s[i] == 'n') printf("n"); /* Others are just printed as such. */ else printf("%c", s[i]); /* Also insert occasional line breaks. */ if (i % 48 == 47) printf(""n ""); } printf("""); } /* What follows is a string representation of the program code, from * beginning to end (formated as per quote() function, above), except * that the string _itself_ is coded as two consecutive '@' * characters. */ const char progdata[] = "/* A simple quine (self-printing program), in st" "andard C. */nn/* Note: in designing this quine, " "we have tried to make the code clearn * and read" "able, not concise and obscure as many quines are" ", so thatn * the general principle can be made c" "lear at the expense of length.n * In a nutshell:" " use the same data structure (called "progdata"n" " * below) to output the program code (which it r" "epresents) and its ownn * textual representation" ". */nn#include <stdio.h>nnvoid quote(const char " "*s)n /* This function takes a character stri" "ng s and prints then * textual representati" "on of s as it might appear formatted in Cn " "* code. */n{n int i;nn printf(" "");n " " for (i = 0; s[i]; i++) {n /* Certain c" "haracters are quoted. */n if (s[i] == '" "')n printf("");n else if (" "s[i] == '"')n printf(""");n " " else if (s[i] == 'n')n printf("n"" ");n /* Others are just printed as such. *" "/n elsen printf("%c", s[i]);n " " /* Also insert occasional line breaks. */" "n if (i % 48 == 47)n printf("" ""n "");n }n printf(""");n}nn/* What " "follows is a string representation of the progra" "m code, fromn * beginning to end (formated as pe" "r quote() function, above), exceptn * that the s" "tring _itself_ is coded as two consecutive '@'n " "* characters. */nconst char progdata[] =n@@;nnin" "t main(void)n /* The program itself... */n{n" " int i;nn /* Print the program code, chara" "cter by character. */n for (i = 0; progdata[i" "]; i++) {n if (progdata[i] == '@' && prog" "data[i + 1] == '@')n /* We encounter " "two '@' signs, so we must print the quotedn " " * form of the program code. */n {" "n quote(progdata); /* Quote all. *" "/n i++; /* Skip second" " '@'. */n } elsen printf("%c"," " progdata[i]); /* Print character. */n }n " " return 0;n}n"; int main(void) /* The program itself... */ { int i; /* Print the program code, character by character. */ for (i = 0; progdata[i]; i++) { if (progdata[i] == '@' && progdata[i + 1] == '@') /* We encounter two '@' signs, so we must print the quoted * form of the program code. */ { quote(progdata); /* Quote all. */ i++; /* Skip second '@'. */ } else printf("%c", progdata[i]); /* Print character. */ } return 0; } 
Scheme
 ((lambda (x) (list x (list (quote quote) x))) (quote (lambda (x) (list x (list (quote quote) x))))) 

The C Programming Language, Brian Kernighan and Dennis Ritchie, the original edition that served for many years as an informal specification of the language The C programming language is a standardized imperative computer programming language developed in the early 1970s by Dennis Ritchie for use on the Unix operating system. ... Scheme is a functional programming language and a dialect of Lisp. ...

See also

HTML and JavaScript in an IDE that uses color coding to highlight various keywords and help the developer see the function of each piece of code. ... A self-interpreter (frequently called meta-circular interpreter or meta-interpreter) is a programming language interpreter written in the language it interprets. ... Self-replication is the process by which some things make copies of themselves. ... A clanking replicator is an artificial self-replicating system that relies on conventional large-scale technology and automation. ... There are a lot of kinds of listing. ... HQ9+ is a joke programming language created by Cliff Biffle that consists of only four commands, each represented by a single character: H, Q, 9, and +. It is not Turing-complete, but it is highly efficient at certain types of programs. ...

Further reading

Douglas Richard Hofstadter (born February 15, 1945) is an American academic. ...

External links

Wikisource has original text related to this article:
Quines

  Results from FactBites:
 
W.V.O. Quine - definition of W.V.O. Quine in Encyclopedia (1162 words)
Quine roundly rejected the notion that there should be a "first philosophy," a theoretical standpoint somehow prior to and capable of justifying science.
Quine's ontological relativism led him to agree with Pierre Duhem that for any collection of empirical evidence there would always be many theories able to account for it.
For Quine, scientific thought formed a coherent web in which any part could be altered in the light of empirical evidence and in which no empirical evidence could force the revision of a part.
  More results at FactBites »


 

COMMENTARY     


Share your thoughts, questions and commentary here
Your name
Your comments
Please enter the 5-letter protection code

Want to know more?
Search encyclopedia, statistics and forums:

 


Lesson Plans | Student Area | Student FAQ | Reviews | Press Releases |  Feeds | Contact
The Wikipedia article included on this page is licensed under the GFDL.
Images may be subject to relevant owners' copyright.
All other elements are (c) copyright NationMaster.com 2003-5. All Rights Reserved.
Usage implies agreement with terms.