Talk:Quine

Revision as of 04:35, 22 November 2007 by MikeMol (talk | contribs) (full response)

I did not read up as fully as I should have on this task. The program is to output its own source without accessing files. This makes the examples here incorrect. See the wiki for more clarification. --Mwn3d 20:32, 17 November 2007 (MST)

I don't think this task does illustrate the comparative features of different languages very well. As the Wikipedia article explains, one way to solve this task that will work in every language is put the program code into a string, together with some mechanism to replace it at a special location with a copy of itself. For languages which keep a more-or-less one-to-one representation of the code around at runtime (Lisp, Smalltalk, Forth, etc.), it just boils down to accessing this representation. Smaller solutions are in danger of becoming an exercise in obfuscation, or at least become unreadable very quickly. And the examples seen now which mostly access files are obviously missing the point.

So I'd propose to delete this task, and replace it with a task that shows how to access (and maybe manipulate) code at runtime for languages that support it. The general solution can be subsumed by task(s) that show how string manipulation works. Dirk Thierbach 18 November 2007

The name of the task is Quine. A Quine is not allowed to open its source file and to copy it to standard output. All implementations which do this should be removed. 194.48.84.1 05:56, 20 November 2007 (MST)

The task states (perhaps not clearly enough) that the program itself should do the printing, not any toplevel read-eval-print loop, or equivalent. Otherwise, all constants in languages that have such a toplevel would be quines. But that is completely missing the point of the original problem, which (as explained for example in the book Gödel, Escher, Bach) is about self-application, and quoting. -- Dirk Thierbach 21 November 2007

I clarified the task. Different scenarios have different requirements for output. The Lisp example satisfied the spirit of the task (produce a usable reproduction of one's own code), so the task itself needed to be adjusted. I won't take that approach in all cases; It's a matter of the spirit of the task. --Short Circuit 13:06, 21 November 2007 (MST)
I beg to differ - it's not the "scenarios" which have requirement for output, it's the spirit of the task itself which is not correctly presented if you allow constants (or empty programs) as solutions. I strongly recommend to read at least the Wikipedia article, or the book mentioned above (your library should have a copy). The philosopher Quine studied self-reference, as exemplified in the paradox "'Yields falsehood when preceded by its quotation' yields falsehood when preceded by its quotation."
And it's this idea that makes up a Quine - A piece of code, applied to itself, once quoted and once unquoted. (BTW, this then again is the same technique used to prove undecidability theorems.) And the extra requirement "should print it's output" is one way to enforce that the quoting has to be done by the program itself, not by some external read-eval-print loop.
The task is bad enough as it is (it doesn't really help in comparing programming languages), and it's not improved by allowing "fortunate" border cases which take away the main point. Ok, so what's the procedure to resolve differences in opinion? Dirkt 14:16, 21 November 2007 (MST)
To quote the Wikipedia page in question:
In computing, a quine is a program, a form of metaprogram, that produces its complete source code as its only output. For amusement, programmers sometimes attempt to develop the shortest possible quine in any given programming language.

Note that programs that 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 that 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.
While the question that Quine investigated implies the quote-interpreting solution, the definition of the problem (per Wikipedia, anyway), doesn't require it. Reading it over, I'll agree that the Lisp example doesn't demonstrate anything one wouldn't get from Empty Program, and would be better replaced with the Scheme/Common Lisp example from the Wikipedia page. I'd have no problem modifying the task description to discard empty programs as trivial, or even requiring the program to use a human-readable output method. Still, the task can still serve to compare languages. Some languages make accessing the source simple, like in the Forth example, or the JavaScript example on the Wikipedia page. Even the string-modifying solution allows for differences between languages; Different languages have different best solutions for replacing a substring.
It's not a 1:1 technique comparison, but neither is any task with both functional and procedural language examples. Would you be reasonably satisified if the task was changed to require human-readable output and exclude empty programs? --Short Circuit 21:35, 21 November 2007 (MST)
Return to "Quine" page.