Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is quine meant for?

So I just came across the term Quine on Wikipedia and cannot figure out what the heck it is meant for. I'm more than confused about it. Are there any real-world uses for it?

like image 801
tomsseisums Avatar asked Apr 28 '12 22:04

tomsseisums


People also ask

What is the meaning of quine?

(philosophy) To deny the existence or significance of something obviously real or important.

How do you use quine in a sentence?

Quine believed that science and philosophy are in the same boat. Quine was a gifted mathematician, and was attracted to philosophical speculation, but neither recondite mathematical research nor forays into the canon of great philosophers appealed to his intellectual temperament.

How do you spell quine?

Quine Definition & Meaning | Dictionary.com.

What does Bonnie quine mean?

Meaning: A young woman. Example: 'She's a bonnie lookin' quine' Translation: 'She's a beautiful young woman'


2 Answers

Quine is essentially a command that outputs its own source code. And no there really aren't any practical uses for it.

like image 145
arshajii Avatar answered Oct 14 '22 15:10

arshajii


A quine is useful in the following scenarios:

  • Programmatic compilation

Object code may be serialized to disk directly, though it has a cookie and version prepended to the front. But when compiling Scheme at run time, you want a Scheme value: for example, a compiled procedure. For this reason, so as not to break the abstraction, Guile defines a fake language at the bottom of the tower:

Value 

Compiling to value loads the object code into a procedure, and wakes the sleeping giant.

Perhaps this strangeness can be explained by example: compile-file defaults to compiling to object code, because it produces object code that has to live in the barren world outside the Guile runtime; but compile defaults to compiling to value, as its product re-enters the Guile world.

Indeed, the process of compilation can circulate through these different worlds indefinitely, as shown by the following quine:

((lambda (x) ((compile x) x)) '(lambda (x) ((compile x) x)))
  • Security checking:

In the Omniture case an attacker needs to add the quine in the cookie and then force the eval using a new value for the cid

Using a crafted gzip file (the attached file is a quine that unpacks to itself), one can get tar(1) to invoke an infinite chain of gzip compressors until all the memory on the machine running tar(1) has been exhausted or another resource limit kicks in.

  • Self Transformation

Essentially, its intuitive (and effective) content is that a program may use its own source as a variable, i.e. adding to a programming language the ability for a program to manipulate itself (its source code) does not add to its expressive power. So there exists a program that compresses its own listing; there exists one which prints its own MD5 checksum (this is much easier than finding a program — indeed any file — that contains its MD5 checksum

  • Self-Contained Two-Tier Architecture

If your data and the database code are not stored in the same place, you risk losing track of one, making the other useless.

  • Self-Preservation

TiddlyWiki is an unusual example of a practical quine: it is this ability to produce a copy of its own source code that lies at the heart of TiddlyWiki's ability to independently save changes to itself.

  • Proofs

If "quine" means "an automaton using its own source code as input", then Gödel used a quine, more or less, to prove his incompleteness theorem, Turing used one to prove that the halting problem was uncomputable, Thompson used one to show that access to the source code of all of your software and compilers is insufficient to find backdoors in it, Steve Russell approximately invented functional programming languages by encoding McCarthy's Lisp quine into (709?) assembly, John von Neumann predicted that the structure of self-reproducing life forms in general would turn out to be quines, and was proved right with the discovery of DNA.

So if quines are responsible for the existence of life, Gödel's incompleteness theorem, the proof of the uncomputability of the halting problem, and the existence of functional programming languages, I nominate them as the most historically important category of programs of all.

  • Unstructured loops

Muriel has no traditional control structures. Instead, Muriel has a command to replace the currently running Muriel program with a given string, and run that instead. This leads to a programming method where a program must quine itself in order to perform any sort of loop.

References

  • Guile Reference Manual: Compiler Tower

  • Minded Security Blog: God Save The (Omniture) Quine

  • Irresistible programs | Lambda the Ultimate: Quines are the most historically important programs of all!

  • TiddlyWiki: Quine

  • libarchive Issue #660: Possible denial of service using a crafted gzip file

  • QuineDB

  • Quines (self-replicating programs)

  • Quine - Rosetta Code

  • Comparison of Two Population Proportions | R Tutorial

  • Muriel - Esolang

  • A quine in pure lambda calculus - Computer Science Stack Exchange

like image 23
Paul Sweatte Avatar answered Oct 14 '22 16:10

Paul Sweatte