top | item 6048761

Quine Relay

983 points| codeulike | 12 years ago |github.com | reply

177 comments

order
[+] danso|12 years ago|reply
I know we shouldn't care about the source, crazy-insane as he obviously is, but FWIW, the author is Yusuke Endoh, one of the Ruby core members. RubySource had an interview with him here:

http://rubysource.com/meet-fifteen-ruby-core-committers/

He lists his "hobby in programming" as: "writing a Quine and enjoying esoteric programming."

[+] scrumper|12 years ago|reply
I feel awful for pointing this out, but the author spelled Copyright incorrectly in the last line.

Fortunately, he can correct it without blowing out his Ascii art by deleting the extra space between '##' and 'Quine'.

I'd issue a pull request myself, but it'd be like me putting soy sauce on a piece of Jiro Ono's sushi. I am completely unworthy.

[+] ilyanep|12 years ago|reply
I feel like the fact that you took the time to figure out how to fix it makes you at least somewhat worthy.
[+] quchen|12 years ago|reply
But then the cycle would probably not close anymore - the end result would not be the initial code.
[+] cbhl|12 years ago|reply
Wouldn't you also need to fix src/QR.rb.gen.rb?
[+] sans-serif|12 years ago|reply
When I first spotted that, I wasn't sure if it was intentional. Maybe the comments are a part of the input.
[+] Rabidgremlin|12 years ago|reply
If anyone wants to give this a go. I have created a Vagrant config which installs the OS, tools and runs the chain of programs. You can find it here: https://github.com/rabidgremlin/vagrant-quine-relay
[+] candeira|12 years ago|reply
I installed it yesterday. It fails at the point of Jasmin:

jasmin QR.j QR.j:2: Warning - Syntax error.

^ QR.j:2: Error - Couldn't repair and continue parse.

^ QR.j: Found 2 errors

And then completely craps out at the badly generated Java. Any idea of what goes?

[+] jcromartie|12 years ago|reply
The code that generates the quine is included. There's still lots of super impressive stuff here, but don't be intimidated thinking he wrote that monster by hand!

https://github.com/mame/quine-relay/blob/master/src/code-gen...

[+] StavrosK|12 years ago|reply
Anyone care to explain how it works? I can see how the first step "Ruby -> X" is done, but what about "X -> Y"?
[+] lisper|12 years ago|reply
LOL! The codegen for Java is so much longer than any of the others!
[+] Leszek|12 years ago|reply
If anything, that makes it even more impressive.
[+] jetru|12 years ago|reply
My thoughts went from "This is amazing" to "But he must have taken a lot of time and brainpower to do this" to "This is useless really" to "So what? If I wanted to do that I would take a year perhaps if I ever could" to "This is amazing"
[+] boomlinde|12 years ago|reply
As if in line with some sort of sick and twisted version of the Kübler-Ross model
[+] RyanZAG|12 years ago|reply
That is both the most incredible thing I've ever seen, yet also by far the saddest thing I've ever seen. Props to the author for taking dedication to a whole new level.

Link to a description of what this actually is: https://github.com/mame/quine-relay

[+] dustingetz|12 years ago|reply
Its not sad at all. Really good programmers can do things that ordinary programmers think impossible. This code was probably generated. Here is a paper on quine generation[1], and the authors have a very popular talk where they livecode a quine generator; that is, they livecode a program that generates an infinite list of quines[2] (source code from talk [3]).

[1] http://users-cs.au.dk/danvy/sfp12/papers/byrd-holk-friedman-... [2] http://www.infoq.com/presentations/miniKanren [3] https://github.com/webyrd/quines

The talk is amazing and hilarious.

On point, if the code is not generated in this fashion, there is assuredly a "work smart not hard" trick that drastically simplifies the problem.

[+] skrebbel|12 years ago|reply
If you think that anything about this is sad, then you simple don't love programming enough.

There's nothing wrong with not loving programming, but calling people who clearly do "sad" because of it, is a bit, well, sad.

[+] GuiA|12 years ago|reply
I'm sorry, how is that sad?
[+] kragen|12 years ago|reply
Saying that hacking is "sad" is arrogantly elevating your own limited worldview over the worldview of hackers. Perhaps someday you could hope to become as awesome as the person you're criticizing, but first you have to realize that being a hacker is something worth aspiring to.
[+] quchen|12 years ago|reply
In case someone is able to run this beast, I'd appreciate an upload of the intermediate source files.
[+] SilasX|12 years ago|reply
Working on it now. I started a repo where I document the things I had to do to get it to work, i.e. where I had to do something other than what was in Mame's README:

https://github.com/SilasX/QuineRelayFiles

The intermediate source files I've been able to generate so far are in /output_files:

https://github.com/SilasX/QuineRelayFiles/tree/master/output...

Edit: Direct link to the go file:

https://github.com/SilasX/QuineRelayFiles/blob/master/output...

Edit2: I ended up copying so much of what was already there that I re-did this as a fork, adding my contributions in two directories (installation and intermediate):

https://github.com/SilasX/quine-relay

So far I'm stuck at an issue with the Pascal compiler not accepting long strings, which can be fixed either with a compiler switch or by editing the source earlier in the relay.

https://github.com/mame/quine-relay/issues/3

[+] vedant|12 years ago|reply
I successfully compiled every intermediary, and posted all of the code in a gzipped tarball here: http://goo.gl/EBZFV.

I also made an EC2 AMI, ID ami-744b351d, for anyone who would like to try this themselves.

I started a tiny stub post here, where I'd like to dig into the code over the next couple of days: http://vedantmisra.com/2013/07/yusuke-endohs-amazing-quine-r...

I posted about it earlier in a reply here to OP.

[+] sker|12 years ago|reply
I made it to the first Fortran, 24 out of 50:

    gfortran -o QR QR.f && ./QR > QR.f90
    gfortran: internal compiler error: Killed (program f951)
Giving up now.
[+] mbillie1|12 years ago|reply
I'm grabbing the packages (in Ubuntu 12.04, just sub "clojure1.4" with "clojure" and you should be able to grab them all)... will attempt to run it once I get this all set up.
[+] shurcooL|12 years ago|reply
Yeah, I want to see the golang code.
[+] avivo|12 years ago|reply
This should be in MOMA.
[+] tome|12 years ago|reply
Why's there a Star of David in the middle?
[+] _pmf_|12 years ago|reply
Day 5462 on the internet.

Today, I have seen true madness.

[+] codeulike|12 years ago|reply
NB: I originally posted this with the link pointing to the QR.rb file, which is the main code file and also a piece of Ascii art. Looks like the mods switched the link back to the main project to provide more context. But to have people looking at QR.rb first and then reading about what it does afterwards was the idea. Amazing piece of work by @hirekoke.

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

[+] zw123456|12 years ago|reply
This reminds me very much of the various types of mathematical exercises that seem to be very esoteric and academic but turned out to be very useful in some solution in physics (eg. lorentz contractions). I would not be surprised if some insight indirectly comes from this insanely amazing exercise.
[+] GhotiFish|12 years ago|reply
It terrifies me what this insight might be.