Non-cheating self-replication programs (Quines)

Just for fun, here are some short self-replicating programs I created in JavaScript, PHP and Perl. These don't cheat in the sense that they don't use language features that print sources of functions, access the file or script of the program or similar.

Most of these use the following structure:

a="print('a="'.a.'";'.a);";print('a="'.a.'";'.a);

The complication is to be able to include a (double) quote (orange) inside a string that uses the same delimiter (green). Perl can do this as it matches braces in the q{} notation; in JavaScript I used code to create these characters. In PHP it was even more difficult, so I went for a different solution entirely.

Popular Posts