Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

While this is amazing, I should point out that for most languages he only needs to understand enough syntax to print strings and possibly unquote them. If you actually run this program into the first language, Ruby, the actual code (meant to be a Rust code) is as follows:

    fn main(){print!("{}",("object QR extends App{print(\"(display \\\"printf(\\\\\\\"1d;s/.//;s/1/ the sum of a son and0/g;s/0/ twice/g;s/2/You are as bad as/g;s/3/ a son!Speak your mind!/g\\\\\\\\n#The Relay of Quine.\\\\\\\\n#Ajax, a man.\\\\\\\\n#Ford, a man.\\\\\\\\n#Act i: Quine.\\\\\\\\n#Scene i: Relay.\\\\\\\\n#[Enter Ajax and Ford]\\\\\\\\n#Ajax:\\\\\\\\n#\\\\\\\");function[]=f(s);for i=1:2:length(s),printf(\\\\\\\"2%s3\\\\\\\",part(dec2bin(hex2dec(part(s,i:i+1))),$:-1:2)),end;endfunction\\\\nf('[lots of hexdump]')\\\\nf('[lots of hexdump]')[snip]\\\\nprintf(\\\\\\\"\\\\\\\\n#[Exeunt]\\\\\\\");quit\\\")\");}"));}
...where `("object ... ;}")` part is a single string literal here. The actual quine stuff can be done in just one language at your choice, or can be assimilated into some other language where unquoting is a bit heavier. It is much easier than polyglots, where a single code should be interpreted in multiple languages.


Printing and unquoting strings is enough to write an ordinary quine (although getting it exactly right is still quite subtle).

Making a quine relay is substantially more complicated, because you don't just print the quoted string, you have to print the quoted version of a string in a different language, but that unwraps to the same thing 128 applications later!

If you still think it's easy, I reckon you should write us a quine relay of just 3 languages and then explain how simple it is.


"Easier than polyglot" does not mean "easy". :-) But I took a bit of time to produce a three-language quine relay elsewhere in this thread [1], and it is relatively easy to follow. The quine stuff (and thus every necessary quoting) is done in Ruby here, Python and Java only prints an appropriately quoted string.

Of course there should be several intermediate steps to keep the number of quotes reasonable (since it will be exponentially increasing in most languages), and that's probably why there are hexdumps after about 20ish languages.

[1] https://news.ycombinator.com/item?id=33109200


Great job, respect!


He didn't say it was easy at all, he simply pointed out that the required knowledge of each language is a subset of the total available functionality of each language.


In this video (where among the other things they explain huroboro), they show an example of code that prints out exactly the same output (itself) whether it's compiled/executed in c, python or ruby

https://youtu.be/6avJHaC3C2U?t=1957




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: