News for hackers. Stuff that matters.
Re:Quine Relay by terabytest on Monday July 15, 2013 @06:41PM (#6048996)
Anyone care to explain how this actually works?
Re:Quine Relay by jkbyc on Monday July 15, 2013 @07:04PM (#6049086)
It is based on the recursion theorem from computability theory: http://en.wikipedia.org/wiki/Kleene's_recursion_theorem

It is a fun exercise to understand the theorem and its proof (and still probably easier than creating an actual quine).

Re:Quine Relay by wiredfool on Monday July 15, 2013 @07:32PM (#6049189)
I thought I understood recursion, but apparently I need to understand recursion first.
Re:Quine Relay by SilasX on Monday July 15, 2013 @06:44PM (#6049007)
Per the explanation linked in the discussion [1], the initial file generates code in another language. That code, when executed, generates code in yet another language. The process continues until the output is the code of the original file.

[1] https://github.com/mame/quine-relay

Re:Quine Relay by terabytest on Monday July 15, 2013 @06:48PM (#6049030)
What is unclear to me is how the final program manages to represent the entire code (thus the entire language loop). Wouldn't doing that make the source code recursive and infinite? Or am I missing something important?
Re:Quine Relay by shawnz on Monday July 15, 2013 @07:42PM (#6049222)
If you look at the ruby source file[1], you'll see that the first thing it does is take all of its source and put it in a variable $s. Then it evaluates the source code in that variable, with that source having access to itself as a string. All of the intermediate representations could easily contain this string in its entirety (and they likely do). Hopefully you can see now how it's not so impossible (but still ridiculously awesome!)

[1] https://github.com/mame/quine-relay/blob/master/QR.rb

Re:Quine Relay by thedigitalengel on Monday July 15, 2013 @08:16PM (#6049339)
Representing self is actually not that difficult or mind-bending; you just need a representation that is isomorphic to the program source. For instance, you could store the ASCII symbols in an integer array:

  int array = { ... } // holds the source code,
                      //  except its own representation

  int array_index; // The index in the source code
                   // (where the actual integers in
                   // array interpreted as source appear)

  for i = 0 to array_index:
    print (array[i] as an ASCII character)

  for i = 0 to array_length:
    print (array[i] as integer ++ ", ")

  for i = array_index + 1 to array_length:
    print (array[i] as an ASCII character)
The core idea is that you can interpret `array` in two ways, as an array of integers or an array of ascii characters representing the program source. The only difficult part is adjusting array_index. With a little effort, this can be scaled to a chain of languages.
Re:Quine Relay by baddox on Monday July 15, 2013 @07:07PM (#6049098)
We already have lots of single-language quines, which are programs that output exactly their own source code when evaluated. In other words, there's a text C and a function F such that F(C) == C (i.e. C is a fixed point of F), where F is a single programming language evaluator and C is a source code file.

In this case, however, the function F happens to be the composition of a bunch of individual functions. So F is equivalent to Rexx ∘ R ∘ Python ∘ Prolog, but with many more functions composed than I am willing to type right now. This doesn't change the nature of what we're searching for, which is simply a fixed point of a given function. Realistically, of course, it makes it more difficult and impressive for someone to actually accomplish, but mathematically/computationally speaking it's the same thing.

Re:Quine Relay by recuter on Monday July 15, 2013 @07:03PM (#6049084)
https://github.com/mame/quine-relay/blob/master/src/code-gen...

This is a neat project but somehow the implementation is a lot less mind bending than the definition. Which is rather the opposite of what I experienced when I first heard of a Quine and figured out how to write one (http://en.wikipedia.org/wiki/Quine_(computing), Turbo Pascal in my case, heh).

This smacks of something else, perhaps art.

Re:Quine Relay by woobles on Monday July 15, 2013 @09:09PM (#6049488)
Look at that Wikipedia article under "Multiquines"
Re:Quine Relay by SilasX on Monday July 15, 2013 @06:50PM (#6049040)
No more recursive or infinite than any other self-replicator that has intermediate "bodies".

EDIT: To clarify, there's actually a wrapper script on top of it all that tells the first script to execute, storing its output in file 2, then execute file 2 with language 2, then execute file 3 with language 3, and so on.

Re:Quine Relay by kragen on Tuesday July 16, 2013 @02:15AM (#6050269)
Quines work the same way as cellular reproduction. I don't think there are any life forms that carry alternation of generations out to 50 different stages, though; the most I've heard of is two.