A quine is a computer program that takes no input and produces a copy of its own source code as its only output.
Quines are possible in any Turing-complete programming language, as a direct consequence of Kleene's recursion theorem.
The name "quine" was coined by Douglas Hofstadter, in his popular 1979 science book Gödel, Escher, Bach, in honor of philosopher Willard Van Orman Quine (1908–2000), who made an extensive study of indirect self-reference, and in particular for the following paradox-producing expression, known as Quine's paradox: "Yields falsehood when preceded by its quotation" yields falsehood when preceded by its quotation.
Later, Paul Bratley and Jean Millo's article "Computer Recreations: Self-Reproducing Automata" discussed them in 1972.
The "download source" requirement of the GNU Affero General Public License is based on the idea of a quine.
The following shell script is not a quine: A shorter variant, exploiting the behaviour of shebang directives: Other questionable techniques include making use of compiler messages; for example, in the GW-BASIC environment, entering "Syntax Error" will cause the interpreter to respond with "Syntax Error".
The quine concept can be extended to multiple levels of recursion, giving rise to "ouroboros programs", or quine-relays.
Unlike quines and multiquines, polyglot programs are not guaranteed to exist between arbitrary sets of languages as a result of Kleene's recursion theorem, because they rely on the interplay between the syntaxes, and not a provable property that one can always be embedded within another.