This 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.
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.
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.
Comments
This 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.
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:
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.