3 ms·
The author has explained it, here: http://d.hatena.ne.jp/ku-ma-me/20130715/p1 http://d.hatena.ne.jp/ku-ma-me/20130715/p1 In the "spoiler" section: """ Normall
by omoikane 13y ago
The author has explained it, here:
http://d.hatena.ne.jp/ku-ma-me/20130715/p1 http://d.hatena.ne.jp/ku-ma-me/20130715/p1
In the "spoiler" section:
"""
Normally quines are made like this:
s = (something that generates your own source code)
puts s
At the same time, a Ruby program that outputs a Perl program looks like this:
puts "print(\"...\");"
If you combine these with quine methods, you get a multi-quine that goes between Ruby and Perl:
s = (something that generates your own source code)
puts "print(\"#{ s }\");"
Theoretically you just repeat this process. Except, there are the following practical problems:
- Need proper escaping
+ Lots of old languages do not support C style of escape sequences.
+ Depending on languages, you need to escape interpolations.
- Cobol and Fortran programs have troublesome constraints
+ Need 7 spaces on the left and less than 80 columns per line, etc.
- Naive escaping will cause intermediate files to get too large.
+ JVM Strings have 64K size limit.
+ Languages like Intercal and Whitespace will become unbearably slow.
In order to avoid these, Perl requires something like ppencode, Java needs LZW compression to avoid string size limits. Cobol's line length limit was satisfied using Closure generator, Fortran's line length limit was satisfied using Coffeescript generator. People who are interested should see the generated code.
"""
In general, there isn't any standard method to making quines. You just keep on tweaking the code until the input and output matches, mostly by trial and error.