3 ms·
Quines are fun! My favorite generalization is the quine relay: "This is a Ruby program that generates Rust program that generates Scala program that generates .
by brian_cloutier 7y ago
Quines are fun! My favorite generalization is the quine relay: "This is a Ruby program that generates Rust program that generates Scala program that generates ...(through 128 languages in total)... REXX program that generates the original Ruby code again." https://github.com/mame/quine-relay https://github.com/mame/quine-relay
The same author also has a radiation-hardened quine, which still emits the original quine even if you delete any(!) one character before running it: https://github.com/mame/radiation-hardened-quine https://github.com/mame/radiation-hardened-quine
But coming back to traditional quines; the most common solution is of the form:
> The following string followed by itself in quotes: "The following string followed by itself in quotes: "
This is by no means the only possible solution: If you view the compiler/interpreter as a function then a quine is the fixpoint of that function.
So, if your "compiler" is `cat`, the shell identity function, then any string is a quine! A fork bomb is also a kind of quine. The quine there is not the code itself, but a process running the code. That process is "interpreted" by the kernel, which dutifully creates an exact copy of the fork-bomb process.
I've never sat down and tried it, but one day I want to write a quine of the form: "Initialize a PRNG with this seed and print the first n bytes". Probably there's a language which lets you get the required code small enough that you could brute-force the correct seed.
- andrewflnr 7y agoOne of my favorite (pseudo?-) quines is the shell script #!/usr/bin/cat
- lelf 7y ago10 LIST
- earenndil 7y agoThat's a cat-script, not a shell-script.
- andrewflnr 7y ago...fair enough. What's the general term for a shebang-ified text executable?