14 ms·
A Ruby program that generates itself through a 128-language quine loop
- polycaster 4y agoBut does it run Doom?
- bilekas 4y agoThis is insane.. I remember when it was only 50 and I was blown away.
- raydiatian 4y agoHow exactly does this work? Does one language invoke another and another in a chain, or ruby at the top calling A, then B, then C.. And is that an Ouroboros snake, or something else
- viraptor 4y agoThe top of the repo explains it: https://github.com/mame/quine-relay https://github.com/mame/quine-relay
- bheadmaster 4y agoI am amazed. I have no idea how the hell could the author even do that. Apparently, they have a book called "The world of obfuscated, esoteric, artistic programming", but it seems to be written in Japanese. I hope it will be translated to English someday, so I may learn this dark sorcery.
- obfuscationeso 4y ago
- alrlroipsp 4y agoI don't care if you share hollywood movies but I find it a bit appauling you just keep posting this crappy autotranslate of his in-print book. This guy deserves some sales, he's legend.
- bheadmaster 4y agoAn argument could be made that, until he releases an English version, the crappy autotranslate version is better than nothing, and doesn't actually harm his sales, since the people who know Japanese will not care for the crappy autotranslate version, while people who don't will not care for the Japanese version. Though, I personally found the autotranslate version somewhat unreadable, so I'll probably wait for the author's translation.
- obfuscationeso 4y agoI doubt he is loosing any sales because of this. You can't even buy the book outside of japan. I would 100% buy the book if I was able, but at the moment the best that is available is this crappy google translate version.
- deleted 4y ago[deleted]
- _k9eq 4y agoThis was written by Yusuke Endoh, who also wrote this submission to the IOCCC that I remember being arguably more astonished when I saw it for the first time: https://www.youtube.com/watch?v=QMYfkOtYYlg https://www.youtube.com/watch?v=QMYfkOtYYlg (ASCII fluid dynamics).
- sixstringtheory 4y agoWow, that was cool, never found that one when I went on a deep dive after discovering their quine relay. The other amazing ASCII program of theirs that I love is the Qlobe: http://mamememo.blogspot.com/2010/09/qlobe.html?m=1 http://mamememo.blogspot.com/2010/09/qlobe.html?m=1
- tromp 4y agoSome background: https://esoteric.codes/blog/the-128-language-quine-relay https://esoteric.codes/blog/the-128-language-quine-relay Note that the author made the challenge even harder by sorting the languages in alphabetical order: > According to Endoh, the most challenging transitions were Befunge to BLC8 to brainfuck, as all three are esoteric. It runs through languages strictly in alphabetical order, so there was no opportunity to group easier-to-work-with languages together.
- RektBoy 4y agoOf course author is from Japan, of course.
- kubb 4y agoMany programmers complain that they can't complete a hello world example in one or more of the languages featured here because they're too difficult. This guy demonstrated enough understanding of 128 of them to make this work. Is the difference in competence really so big between us?
- Bloedcoin 4y agoYes. I see this every single day. And it becomes more and more obvious the better you become.
- lifthrasiir 4y agoWhile 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.
- sirnicolaz 4y agoIn 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 https://youtu.be/6avJHaC3C2U?t=1957
- jstanley 4y ago
- pushedx 4y agoOne of the languages is Piet. Now that’s insane.
- Liquix 4y agoA work of art :) Previous discussion: https://news.ycombinator.com/item?id=6048761 https://news.ycombinator.com/item?id=6048761 (177 comments) (2013)
- mmohtasim 4y agoIs there any 2 or 3 language version of this? Like ruby to python to java to ruby?
- lifthrasiir 4y agoHere it is: a='print("""class q{public static void main(String[]a){System.out.println("a=#;a[35.chr]=39.chr+a.gsub(34.chr,92.chr*3+34.chr)+39.chr;puts a");}}""")';a[35.chr]=39.chr+a.gsub(34.chr,92.chr*3+34.chr)+39.chr;puts a Run with `ruby q.rb | python - > q.java && javac q.java && java q`. Pretty sure that you can shorten this, I didn't take much time to do that.
- jmartin2683 4y agoIt’s amazing what people can do with stuff like this. Such a beautiful language (Ruby) made so ugly yet beautiful when viewed from a higher altitude.. there’s a metaphor there somewhere
- belter 4y agoI like the Radiation-hardened Quine: https://github.com/mame/radiation-hardened-quine https://github.com/mame/radiation-hardened-quine
- jvanderbot 4y agoI don't even understand how this is possible. My mind runs to CRC or error correcting codes, but how you'd use it is beyond me.
- avg_dev 4y agoI never zoom out on GitHub, but this one time it was kind of neat.
- ramigb 4y agoNow this is how you market a book. cool.
- neilwilson 4y agoDisappointed there is no Eiffel
- whage 4y agoKen Thompson wrote in his famous paper [1] about quines: > If you have never done this, I urge you to try it on your own. The discovery of how to do it is a revelation that far surpasses any benefit obtained by being told how to do it Every once in a while I give them a try but I couldn't yet create one and it frustrates me very much. Afraid of being denied that "revelation" I never dared to read his paper past that point. I'm afraid I might never read it because of my ego. 1: https://www.cs.cmu.edu/~rdriley/487/papers/Thompson_1984_ReflectionsonTrustingTrust.pdf https://www.cs.cmu.edu/~rdriley/487/papers/Thompson_1984_Ref...
- 3pt14159 4y agoIt's easier in some languages than others. There is a delight in doing it, but don't overdo the anticipation. I've found greater delights in programming.
- behnamoh 4y ago> It's easier in some languages than others. Yes, it seems Lisp wouldn't be appropriate for this.
- kirjavascript 4y agoI wrote a new page describing how to write quines recently[1], but the quine-relay is really above and beyond 1: https://github.com/kirjavascript/quine-howto https://github.com/kirjavascript/quine-howto
- siraben 4y agoThere is an ongoing issue in Nixpkgs[0] to package this quine, more help would be appreciated! [0] https://github.com/NixOS/nixpkgs/issues/131492 https://github.com/NixOS/nixpkgs/issues/131492
- enviclash 4y agoCode that writes code that writes code... my limited experience combining AWK and GAMS gave me impressively powerful feelings about my limited code. This surely belongs to the next level, I'll go for more!
- drcabana 4y agoLast December I had the itch to do some blogging. As it happens, I wrote a four part series that explains in detail how to write quines and quine relays. The initial post can be found at https://drcabana.org/quine/ https://drcabana.org/quine/ I am a longtime lurker and finally decided to join in order to comment on this thread. I hope that it is not inappropriate to post a link to my own take on this material. If it is, please accept my apologies and feel free to downvote/flag me out of existence.
- feintruled 4y agoGreat write up, thanks for posting.
- drcabana 4y agoThanks for the kind words. Now I know at least one person has read it.
- debdut 4y ago
- faitswulff 4y agoThis issue imploring Yusuke Endoh to write a paper about it is amusing: https://github.com/mame/quine-relay/issues/10 https://github.com/mame/quine-relay/issues/10 > p-e-w: > This is more than a cool program – it's a computer science breakthrough! Apparently, you have discovered a method for constructing quines based on an arbitrary blueprint involving any amount of languages. > > Please write a technical paper describing your approach. I'm sure you'll have no trouble finding a CS journal that will publish it. > mame: > Okay I'll submit to the Journal of Universal Rejection. Later: > mame: > I'll soon publish a book, "The world of obfuscated, esoteric, artistic programming". The book explains how to write a uroboros quine. Hence, I proudly close this issue. > It also contains my almost all (about forty) works, including alphabet-only Ruby program, radiation-hardened quine, etc., and explains many techniques to write such programs. > You can buy my book on amazon.co.jp. Unfortunately, it is written in Japanese, yet another esoteric language. I hope anyone can translate to English.
- obfuscationeso 4y ago
- dwheeler 4y agoThis article explains the basic idea: David Bertoldi's "How to write your first Quine program" https://towardsdatascience.com/how-to-write-your-first-quine-program-947f2b7e4a6f https://towardsdatascience.com/how-to-write-your-first-quine... However, that article is a basic introduction. This 128-language quine loop is beyond expert, bordering on magic.
- mrtweetyhack 4y ago
- sixothree 4y agoThe real difficulty is getting 128 languages to compile.
- benj111 4y agoIf it's a 128 language loop is it fair to describe it as ruby? The other 127 languages presumably have all the information so you should be able to start and end at any language? I guess in its current implementation the ruby code is the code that ends the loop? But that is optional?
- deleted 4y ago[deleted]
- rdlw 4y ago> I guess in its current implementation the ruby code is the code that ends the loop I don't think so. It looks like the rc code generates the REXX code, which generates the Ruby code, which generates the Rust code.... The only thing that separates Ruby is that it's formatted into ASCII art, although it's not clear if the REXX output is similarly formatted. I can't say I've run through the cycle.