Quine Relay!

A quine relay of order \$n\$ is a series of programs \$P_1\dots P_n\$ in distinct languages such that each program \$P_i\$ outputs \$P_{i+1}\$ and \$P_n\$ outputs \$P_1\$.

For example, a 2-quine relay can be seen here:

Ruby → Perl 6:

This Ruby program:

$><<"print ("
p (DATA.read*2).chars.map(&:ord)
$><<".map: &chr).join"

__END__
$><<"print ("
p (DATA.read*2).chars.map(&:ord)
$><<".map: &chr).join"

__END__

outputs this Perl 6 program:

print ([36, 62, 60, 60, 34, 112, 114, 105, 110, 116, 32, 40, 34, 10, 112, 32, 40, 68, 65, 84, 65, 46, 114, 101, 97, 100, 42, 50, 41, 46, 99, 104, 97, 114, 115, 46, 109, 97, 112, 40, 38, 58, 111, 114, 100, 41, 10, 36, 62, 60, 60, 34, 46, 109, 97, 112, 58, 32, 38, 99, 104, 114, 41, 46, 106, 111, 105, 110, 34, 10, 10, 95, 95, 69, 78, 68, 95, 95, 10, 36, 62, 60, 60, 34, 112, 114, 105, 110, 116, 32, 40, 34, 10, 112, 32, 40, 68, 65, 84, 65, 46, 114, 101, 97, 100, 42, 50, 41, 46, 99, 104, 97, 114, 115, 46, 109, 97, 112, 40, 38, 58, 111, 114, 100, 41, 10, 36, 62, 60, 60, 34, 46, 109, 97, 112, 58, 32, 38, 99, 104, 114, 41, 46, 106, 111, 105, 110, 34, 10, 10, 95, 95, 69, 78, 68, 95, 95, 10]
.map: &chr).join

which in turn outputs the original Ruby program.

The challenge

The first answer will be an order \$1\$ quine relay: a normal quine. It can be in any language.

The next answer will choose a different language and create an order \$2\$ quine relay using those two languages.

And so on. The \$k\$-th answer will create an order \$k\$ quine relay using the previous \$k - 1\$ languages and a new, different language.

Winning

If, after 2 weeks, no more answers have been added, the winner is the person who answered with the highest-order quine relay.

More rules

  • No person may answer twice in a row.
  • No person may answer within an hour of their most recent post.
  • Languages which differ by version are considered distinct. Thus, Python 2 and Python 3 can both be part of the chain.
  • Languages which differ by compiler or interpreter are not considered distinct. So, Python 3 (Cython) and Python 3 are considered interchangeable but not distinct.
  • Each answer may order the languages in any way. If the third answer has an order of Ruby → Perl 6 → JavaScript, you are not restricted to appending a language to the end. If you were adding Java to the mix, then you could write JavaScript → Ruby → Java → Perl 6 if you so desired.

Format for answers

n. Language1 → Language2 → … → Languagen

Language1

language 1 code

Language2

language 2 code

Language3

language 3 code

Languagen

language n code

Feel free to add explanations anywhere in your answers.

  • 3
    You should add something like a 2 character minimum to prevent degenerate quine chains such as the empty string. Also, something to prevent languages that by default echo output their input. Alternatively, you can roll these into one by requiring that all outputs in the chain must be unique. – Yonatan N Aug 10 at 2:53
  • @YonatanN Actually once enough languages get added it would be hard to pull that off... would be interesting to see someone try. Although I think all so far have empty quines. – Ørjan Johansen Aug 10 at 2:56
  • @ØrjanJohansen as of now, someone can trash the question by using a Bubblegum-type language and an empty input. – Yonatan N Aug 10 at 2:59
  • 1
    @YonatanN Hm yeah I guess there are too many ways to abuse it. (Also this kind of thing is why other answer chaining questions give the win to the second last answer.) – Ørjan Johansen Aug 10 at 3:03
  • 2
    @YonatanN 0 or 1 character quines usually do not meet our standard definition of quine – Conor O'Brien Aug 10 at 3:30

3. JavaScript → Python 2 → Foo

JavaScript

Classic JS quine. This is a full program which outputs to console:

(f=_=>console.log(`print(${String.fromCharCode(39)}${String.fromCharCode(34)}(f=${f})()${String.fromCharCode(34)}${String.fromCharCode(39)})`))()

Try it online!

Python 2

Python code basically prints out the JS code with quotes:

print('"(f=_=>console.log(`print(${String.fromCharCode(39)}${String.fromCharCode(34)}(f=${f})()${String.fromCharCode(34)}${String.fromCharCode(39)})`))()"')

Try it online!

Foo

Foo code is JS code with quotes:

"(f=_=>console.log(`print(${String.fromCharCode(39)}${String.fromCharCode(34)}(f=${f})()${String.fromCharCode(34)}${String.fromCharCode(39)})`))()"

Try it online!

  • Why not e.g. String.fromCharCode(39,34) to save on the repeated invocations? – ETHproductions Aug 10 at 13:32
  • @ETHproductions I.. actually had no idea you could do that >_< – Downgoat Aug 10 at 21:01
  • Or at least String.fromCharCode(39)+String.fromCharCode(34) to save a little bit ;-) – ETHproductions Aug 10 at 21:13

2. Python 2 → Foo

i used the basic python quine, then added the quotes

python:

_='_=%r;print chr(34)+_%%_+chr(34)';print chr(34)+_%_+chr(34)

Try it online!

foo:

"_='_=%r;print chr(34)+_%%_+chr(34)';print chr(34)+_%_+chr(34)"

Try it online!

1. Foo

Foo

A simple Foo quine:

>&41>&60>&99>&36>&40>&60>&41>&62>&105>&36>&34>&38>&62>&34>&40>&62>&41>&60>&40(<)>(">&"$i>)<($c<)

Try it online!

4. ><> → JavaScript → Python 2 → Foo

><>

'rpp>o<(f=_=>console.log(`print(${String.fromCharCode(39,34,92,39)}rpp>o<(f=${f})()${String.fromCharCode(34,39)})`))()

Try it online!

I've added the classic wrapping string literal, appending 'rpp>o< to the start, and editing it into the center part too.

JavaScript (Node.js)

(f=_=>console.log(`print(${(a=String.fromCharCode)(39,34,92,39)}rpp>o<(f=${f})()${a(34,39)})`))()

Try it online!

I've shortened the String.fromCharCode part as per comments on the last answer. I know this challenge isn't actually code-golf, but it makes me feel better.

Python 2

print('"\'rpp>o<(f=_=>console.log(`print(${(a=String.fromCharCode)(39,34,92,39)}rpp>o<(f=${f})()${a(34,39)})`))()"')

Try it online!

Added the \' for the start of the ><> quine.

Foo

"'rpp>o<(f=_=>console.log(`print(${(a=String.fromCharCode)(39,34,92,39)}rpp>o<(f=${f})()${a(34,39)})`))()"

Try it online!

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.