19 ms·
Radiation-hardened Quine (2014)
- purkka 3y agoThis comes from the same dev known for the 128-language quine relay, where each of the 128 languages prints a program in the next one, looping all the way to the original one. In alphabetical order and as ASCII art, no less. https://github.com/mame/quine-relay https://github.com/mame/quine-relay
- asicsp 3y agoDiscussion for 'quine-relay': https://news.ycombinator.com/item?id=33105706 https://news.ycombinator.com/item?id=33105706 (350 points | 7 months ago | 56 comments)
- swyx 3y agoi just want to know what possesses a man to do such a wonderful thing, and to even know if such a thing is possible before pursuing it i would also watch a 128 hour livestream of him coding it because how do you even start
- Semaphor 3y ago> i just want to know what possesses a man to do such a wonderful thing My impression is, that they are an artist who just happens to use a medium not normally (directly) used for art: Code.
- mtreis86 3y ago> and to even know if such a thing is possible before pursuing it I'm not the creator of that magnificent piece of programmatical art. But I can take a stab at this. As long as the languages are Turing complete it is possible. Any Turing machine can simulate any other Turing machine so once you step up to that level the challenge is keeping your head through the maze of nuances between many of those languages. I think the logic behind it goes something like this, if a language is complete (eg in the Gödel sense) then you can have it produce things that are nonsense in its own language. Anyways I would expect the bulk of the work to be making those incremental step of going from each language to the next. In terms of data shape, I am thinking a linked list. So the final step is to call them all in a nested fashion, bootstrapping each up onto the top of that stack as you go.
- internetter 3y agoOh huh you're absolutely right. Start at the bottom, work your way up
- BoppreH 3y agoThe quines are not simulating each other, they are just printing a string after some formatting (which usually involves embedding a copy of the string into itself). There's no Turing completeness needed (most of the quines don't even have branches), much less Gödel encodings.
- Izkata 3y ago> they are just printing a string after some formatting There's (at least) one language in quine-relay that's not that simple: Piet. It's a visual 2D language written as an image file. https://www.dangermouse.net/esoteric/piet/samples.html https://www.dangermouse.net/esoteric/piet/samples.html
- rattray 3y agoHe's got a book! ...in Japanese. I hope someone can help him translate it into English so more people can learn about this kind of thing and he can be rewarded for his adventures.
- riffraff 3y agomame (yusuke endoh) also has a pretty awesome youtube channel which is basically just showing their hacks https://www.youtube.com/@YusukeEndoh https://www.youtube.com/@YusukeEndoh
- deleted 3y ago[deleted]
- BoppreH 3y agoThis project has always fascinated me, so I tried making a tiny uroboros quine with Python -> Javascript -> Python -> etc. I started with a quine for each language, and tried inserting them into each other, but the output always grew exponentially. py_quine_template = "s = {}; print(s.format(repr(s)))" py_quine = py_quine_template.format(repr(py_quine_template)) js_quine_template = "s = {}; console.log(s.replace('{}', JSON.stringify(s)))" js_quine = js_quine_template.format(repr(js_quine_template)) py_js_quine = py_quine_template.format(repr(js_quine_template)) ??? So I checked how it's done in the Github repo[1], but the language snippets only seemed to be quoting and printing without any self-references like you'd expect in a quine... Then it hit me. You only need the quine machinery in one language. If I can make a Python script that has a string with its own source code, then the Javascript code will simply be `console.log(py_source)`, no manipulation necessary. So here's my Python/Javascript uroboros quine: s = "s = {}\npy_source = s.format(repr(s))\nprint('console.log('+repr(py_source)+')')" py_source = s.format(repr(s)) print('console.log('+repr(py_source)+')') If there were more languages, then it'd be `console.log("System.out.println({python_source})")`, etc. The problem then becomes escaping inner quotes, and escaping the escape characters themselves. I managed to sidestep the issue by using two types of quotes, and relying on Python's `repr` also giving valid JS strings, but if I had to add just one more language I'd need a lot more scaffolding. I still think the Quine Relay is a tour de force, but now for different reasons. It's not 128 quines in different languages, but an incredibly robust system for escaping strings in 128 wildly different languages. [1] https://github.com/mame/quine-relay/blob/master/src/code-gen.rb https://github.com/mame/quine-relay/blob/master/src/code-gen...
- saalweachter 3y ago> but an incredibly robust system for quoting and escaping strings in 128 wildly different languages I'm getting a tension headache just thinking about it.
- juliusgeo 3y agomame is also very well known for their IOCCC submissions. My favorite is https://www.ioccc.org/2012/endoh1/hint.html https://www.ioccc.org/2012/endoh1/hint.html.
- fouronnes3 3y agoThis is absolutely incredible. Definitely one of those 'I will never understand how" black magic levels of impressive.
- dspillett 3y agoI'm quite confident I understand what is going on with such things, so it isn't black magic to me, but I doubt I'd be able to implement these tricks to do something like this myself in any practical amount of time.
- jerjerjer 3y agoMostly impressed that it's not two redundant copies of a source code, but rather one actual code fragment.
- deleted 3y ago[deleted]
- veleek 3y agoThere are multiple versions in the repo. The first one is essentially just two copies, the second was an improved design from someone else and the last was an ASCII-art version (of the radiation symbol) that was based off the second.
- est 3y agoholy .... even more impressive, it was created 9 years ago!
- lostlogin 3y agoIt is. ChatGPT will write a ‘hello world’ that survives character deletions. I’m pretty impressed it can do this.
- cnity 3y agoChallenge: a self-healing version of this where the program missing a character outputs the original program (with the character re-inserted).
- asicsp 3y agoThat's what this program is doing - the mutated code with one character missing will output the original program.
- cnity 3y agoYou're right! I misread the diff command after mutation. Amazing!
- deleted 3y ago[deleted]
- quickthrower2 3y agoI think it would be more impressive if it produced itself (with character removed) after a character is removed
- Alifatisk 3y agoI follow mame, always up to something fascinating!
- lordnacho 3y agoHow... does it work? What happens if you delete one of the characters in "eval"? What's the space in "e xit" about?
- dspillett 3y agoNot sure about “e xit” off the top of my head, this isn't one of my “natural” languages, but I assume breaking eval is protected against by the multiple invocations and the fact that assignment is an operator that returns its result as well as setting the target variable. If one of the evals is broken (or one of the =s between is removed) it just becomes a variable that is assigned to and the result is passed along. Three evals is enough to give the “any single character deleted” survivability, for “any two characters” you would need five (and many of the other tricks would need to be altered/expanded also).
- NickHoff 3y agoSee also the International Obfuscated C Code Contest. [0] This program [1], for example. It just accepts some input on stdin and returns the same input, but mirrored along the diagonal. So the first row of the input becomes the first column of the output, second row becomes second column, etc. But the program is functionally invariant when given itself as input. In other words, you can flip the source code of the program along its diagonal and the result is a program which has the same functionality - it flips stdin. Or this one [2], which parodies java in C. It's functional C code that looks like Java, including the class LameJavaApp { /** The infamous Long-Winded Signature From Hell. */ public static void main(String[] args) ... Or this one [3] that calculates pi by estimating its own surface area. Or this one [4]. It's a lovers quarrel, written simultaneously in C and English. It's incredible, seriously, read it. [0]: https://www.ioccc.org/ https://www.ioccc.org/ [1]: https://github.com/ioccc-src/winner/blob/master/1994/schnitzi.c https://github.com/ioccc-src/winner/blob/master/1994/schnitz... [2]: https://github.com/ioccc-src/winner/blob/master/2005/chia/chia.c https://github.com/ioccc-src/winner/blob/master/2005/chia/ch... [3]: https://github.com/ioccc-src/winner/blob/master/1988/westley.c https://github.com/ioccc-src/winner/blob/master/1988/westley... [4]: https://github.com/ioccc-src/winner/blob/master/1990/westley.c https://github.com/ioccc-src/winner/blob/master/1990/westley...
- deadcore 3y agoNumber 2 really did make chuckle!
- throwaway744678 3y agoI struggled a bit too long to build it: don't forget the `-w` flag (disable all warnings): cc -w chia.c -o chia
- goolz 3y agoIt would seem that the author of this code is actually the World No. 1 IOCCC champ!
- TheGoddessInari 3y ago(2014)
- myfavoritedog 3y ago[dead]
- jheriko 3y agodoes it work if you flip any random bit though? no.
- xigoi 3y agoSomeone managed to create a level 3 radiation-hardened quine in Perl (you can remove any 3 characters and it still works): https://codegolf.stackexchange.com/a/100785/98955 https://codegolf.stackexchange.com/a/100785/98955
- londons_explore 3y agoAt the most basic, you just have N+1 copies of the program, and run whichever one is longest, since that must be the one with no missing characters. The program itself then prints N+1 copies of itself... You just need a little care about the start of the first program, since that is the 'entry point' - it needs to fall through to the 2nd program if the first is damaged.
- sebzim4500 3y agoThe code that checks which one is longest needs to be resilient to missing characters
- jorvi 3y agoPlus, a bit flip doesn’t necessarily remove a character..
- mwhitfield 3y agoThe "radiation hardening" aspect is metaphorical, this is referring specifically to removing characters, not bit-flips from gamma rays.
- asimpletune 3y agoIs DNA a radiation hardened quine? I mean, it’s basically code that makes more of itself, even in the presence of mutations.
- quickthrower2 3y agoMaybe it is the cell that is the quine?
- laci37 3y agoIt pretty much is, but it's not rad hard in the sense that you can change or delete any one letter. Well, maybe in animals and plants, since we have at least two copies of most genes.
- enkid 3y agoDNA doesn't make a copy of itself, the cell makes a copy of the DNA. DNA doesn't really do anything, it requires RNA and proteins to actually do anything.
- rebolek 3y agowell, quine program doesn't do anything by itself too, you need computer and electricity for it to work
- enkid 3y agoThere's a definitional problem here. Would a book with instructions for how to order additional copies be a quine? What's the difference? I don't know exactly.
- mtlmtlmtlmtl 3y agoI guess the right question to ask about DNA is, does it contain all the instructions required to produce a copy of the DNA itself? DNA translation involves a bunch of RNA, sure. But DNA copying is mostly done by DNA polymerases, which are typical peptide based proteins encoded in the DNA itself, right? So in a real sense, the DNA contains the blueprint for the machinery to copy the DNA itself, but not the instructions for building that machine from the blueprint, the same way a software quine doesn't necessarily include the source code for a compiler. Definitely a definitional problem, but that's my shot at resolving it a bit. Then again, DNA polymerase is not perfect, and DNA is not immune to single nucleotide changes having a real effect, so it's only a quine in the "spherical cow" way of looking at it anyway. But it's certainly the most "quinish" thing in nature that I can think of.
- nkit 3y agoIIRC I saw an interpreter somewhere where each input program is quine, the interpreter name rhymed with `hat` as I remember it.
- tus666 3y agoEh its not a quine anymore.
- internetter 3y agoHow so?
- tus666 3y agoI quine prints it's own source code. This essentially prints an older version of itself.
- internetter 3y agoBut it does print it's source code if you don't modify it. It's like saying that it's not a quine because you formatted it.
- tus666 3y agoThe unmodified version is obviously still a quine. The modified version is not. And yes, formatting matters!
- internetter 3y agoAgreed, but no one ever asserted that it is a quine no matter what. It is a quine that just so happens to still run after decay
- sarabande 3y agoFYI: A quine is a computer program which takes no input and produces a copy of its own source code as its only output.
- GistNoesis 3y agoHere is something quite similar I've just made, but in the image domain : https://github.com/unrealwill/uncroppable https://github.com/unrealwill/uncroppable It's a tool POC to steganographically encode an image into itself to make it crop resistant.
- mabbo 3y agoNow can we go further and add self-healing? Include a checksum somewhere. Modify the output or the checksum until they agree. This is starting to sound like how the immune system works actually...
- internetter 3y agoIt is self healing. The output matches the original
- willis936 3y agoWhat are the advantages to radiation hardening software? In the cases I've run into the thinking has been "if you can't trust the hardware then you're already lost".
- capableweb 3y agoProtecting against cosmic bitflips for example, relevant if you write software that ends up on airplanes/space crafts. Also if you just want resilient software that work even though hardware is starting to fail. See https://en.wikipedia.org/wiki/Soft_error https://en.wikipedia.org/wiki/Soft_error
- willis936 3y agoYes but what is the FMECA case where software is a better domain to address this than hardware?
- capableweb 3y agoI think the point is to implement in software for redundancy, not as an alternative to doing it in hardware. You'll do both essentially.
- deleted 3y ago[deleted]
- supertrope 3y agoDefense in depth. Like the Space Shuttle that had four rad hardened processors. And a voting system to reject anomalous outputs. With two you don't know which one is right. With three you're OK. Four allows for one to permanently fail and still leave three. This is analogous to having at least three NTP servers. Or filesystem level checksums on top of ECC RAM and LDPC in the SSD. Or TCP checksum on IPv4 header checksum on Ethernet/LTE/Wi-Fi checksum.
- xigoi 3y agoIn this case, it's just for fun.
- saint-loup 3y agoNo matter how many times you kill him, Quine rises from his tomb, his hand showing through the dirt to point at a rabbit.
- CrampusDestrus 3y agoWait, what is the definition of radiation hardening? Radiation would flip one random bit at a time, not delete a whole character in one go.
- mistercow 3y agoI think it’s just aesthetically reminiscent of radiation hardening. Pretty sure protecting agains arbitrary bit flips is impossible. If the MSB of the first character gets flipped, the code is illegal no matter what you do.
- bentcorner 3y agoMaybe you could have bit-flip resistant assembly? I hardly know assembly so I don't know if there are opcodes 1-bit apart that could work together.
- shultays 3y agoRadiation would flip a bit though, which more likely changes a character
- le-mark 3y agoThere would also be a difference between deletion and replacing with a space character. Ie shorten the program file by one char (however many bytes depending on encoding). Can anyone explain what deletion means in this useage?
- xigoi 3y agoDeletion means deletion, not replacing with a space.
- xigoi 3y agoThis is what “radiation-hardening” means in the context of programming challenges, it doesn't refer to actual radiation.
- danparsonson 3y agoIf this isn't definitive proof that we live in a simulation, I don't know what is. Seriously impressive work!
- eimrine 3y agoAny known issues when radiation deleted (instead of altering) any characters? Deleting something is introducing significantly more entropy than altering because it alters the length of the array of text, but altering the array requires recalculating of the rest of the array which is impossible outcome of radiation.
- tomxor 3y ago> Prepare a script that deletes one character randomly: Hmm, but can it also deal with general bit flips? Because that's usually what radiation does not delete characters. The only case it would delete a character with a bit flip on the data would be causing the DEL char 0x7F i think, which 7 ASCII chars have a 1 in 8 chance of mutating into (because we have 8 actual bits but only 7 are used for ASCII): ~}{wo_? There are 96 ASCII characters that might be used in source code naively assuming equal character probability that's 7/96 * 1/8 = 0.9% chance of a bit flip deleting a character by mutating into 0x7F. There's also a chance of a character mutating into a non-printable character (0-31), only the 2nd and 3rd column of ASCII can mutate into this by ending up with both high bits off, so there are 64/96 chars with a 1/8 chance that's an 8.3% chance of mutating into a non-printable control char etc (i'm ignoring LF because it displaces DEL). If the 8th bit flips into a one on any char then we get extended ASCII I think, that's 96/96 * 1/8 = 12.5% chance. That leaves 78.3% chance of mutating into another regular printable ASCII character. Apologies for any bad math. There are a lot of possible affects on the interpreter when it sees any of those characters, the control chars could be particularly troublesome. Either way this is still a very cool quine :P
- jonahx 3y agoWhat you're describing just isn't what this game called "radiation hardening" is. It would be a different, also interesting game. But "radiation hardening" challenges are common in code golf, and always (from challenges I've seen) framed in terms of character mutation. Also I suspect some unconscious bias based on your username :P
- tomxor 3y agoAh, I wasn't aware it was the name of a common code golf challenge, I do code golfing myself but apparently not enough :) I guess it makes sense people would frame the game that way, arbitrary bit flips seems way too hard, I'm not even sure it's possible for a program to cope on it's own.
- cubefox 3y agoTo be fair, "radiation" suggests only bit flips.
- defaultcompany 3y agoThe author of this quine (Yusuke Endoh) has a Github repository which encodes a program in the Github contributions graph. I have no idea what the program does but here is a link to the start of it: https://github.com/mame?tab=overview&from=1970-12-01&to=1970-12-31 https://github.com/mame?tab=overview&from=1970-12-01&to=1970...
- rdlw 3y agoIt's a quine!! https://github.com/mame/green-square-quine https://github.com/mame/green-square-quine
- dang 3y agoRelated: Radiation-hardened quine (2014) - https://news.ycombinator.com/item?id=18840797 https://news.ycombinator.com/item?id=18840797 - Jan 2019 (22 comments) Radiation-hardened Quine is now “ascii-arted” - https://news.ycombinator.com/item?id=8318879 https://news.ycombinator.com/item?id=8318879 - Sept 2014 (1 comment) Radiation-hardened quine - https://news.ycombinator.com/item?id=7276976 https://news.ycombinator.com/item?id=7276976 - Feb 2014 (71 comments)
- belter 3y agoRadiation-hardened quine (4 years ago) - 22 comments - https://news.ycombinator.com/item?id=18840797 https://news.ycombinator.com/item?id=18840797 Radiation-hardened quine (9 years ago) - 71 comments - https://news.ycombinator.com/item?id=7276976 https://news.ycombinator.com/item?id=7276976
- kiicia 3y agoHow is radiation supposed to delete character instead of flipping one bit? How is interpreter protected?