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...
I'm getting a tension headache just thinking about it.
i would also watch a 128 hour livestream of him coding it because how do you even start
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.
My impression is, that they are an artist who just happens to use a medium not normally (directly) used for art: Code.
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
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
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.
Most software that does this simply tries to make the test code as small and reliable as possible. But it's an interesting challenge to make the test code somehow self checking with the same properties.
Yes, voting is a common way to deal with radiation or critical software. There are of course also complications about the voting software itself needing to also be redundant. Some can be done with hardware, or you can just radiation harden parts of the system (reducing overall cost).
This is definitely one of those problems where at a quick glance it seems like there's a few simple solutions that can resolve 90% of issues but when you dig into the weeds you find out that 20% dictates most of the outcomes and there's at most a 10% overlap with your quick/obvious solutions.
Roughly speaking it breaks down into a couple categories including the manufacturing of electronics and chips themselves, including everything from substrate differences to using entirely different types of RAM and block storage [0], to the higher level strategies employed by many generations of space probes where a variety of total system redundancy is employed, e.g the Voyager probes used discrete component level redundancy, and most modern probes use almost full system redundancy where they run 3 complete computers in lock step, the idea being that triple redundancy is the minimum needed to detect which computer is wrong.
Another potential strategy not so commonly applied for this purpose is software resilience, such as the techniques applied by the Minix3 microkernel, the idea being to minimise the critical kernel code to be so small that it's unlikely to have bugs or be affected by hardware level affects, then everything else underneath can be kept alive by the kernel, even block device drivers, by employing triple redundancy and a "resurrection server". This was intended to protect against bugs in critical software like device drivers and hardware/firmware bugs rather than radiation, but it could be similarly effective especially as a layered strategy.
[0] https://en.wikipedia.org/wiki/Radiation_hardening#Radiation-...
https://europa.nasa.gov/resources/210/complete-europa-clippe... https://europa.nasa.gov/resources/342/electronics-vault/
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.
[1]: https://github.com/ioccc-src/winner/blob/master/1994/schnitz...
[2]: https://github.com/ioccc-src/winner/blob/master/2005/chia/ch...
[3]: https://github.com/ioccc-src/winner/blob/master/1988/westley...
[4]: https://github.com/ioccc-src/winner/blob/master/1990/westley...
cc -w chia.c -o chiaThe 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.
https://github.com/unrealwill/uncroppable
It's a tool POC to steganographically encode an image into itself to make it crop resistant.
In a nutshell, the DNA fails at protecting from changes all the time, and the immune system is constantly checking for that and killing off those cells.
The DDC model[0] proposes that one of the drivers of evolutionary change is polyploidy, where after an organism has multiple copies of the genome, genes are free to drift into new functions.
An organism with four copies of a gene instead of the usual two is more rad-hardened than the basal non-ploid organism.
[0]: https://www.researchgate.net/figure/The-duplication-degenera...
https://github.com/mame?tab=overview&from=1970-12-01&to=1970...
Radiation-hardened quine (2014) - 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 - Sept 2014 (1 comment)
Radiation-hardened quine - https://news.ycombinator.com/item?id=7276976 - Feb 2014 (71 comments)
Radiation-hardened quine (9 years ago) - 71 comments - https://news.ycombinator.com/item?id=7276976
ChatGPT will write a ‘hello world’ that survives character deletions. I’m pretty impressed it can do this.
Seriously impressive work!
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.
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...
no.