Each language was added by a distinct answer, each answer building on the work of all the previous ones. The community teamwork in building such a monstrosity is beautiful.
Ah, this reminds me of the time I encountered a polyglot "config file" in the wild in a university autograding system.
Instead of being parsed, it was `import`-ed and `include`-d in Python code and Makefiles. It had a `.py` extension so it took me a while to figure out why everything was breaking when I added some Python code in it. All in all, a very cursed setup.
Languages with eval() kind of give you a pass on this challenge.
A more impressive alternative would be writing nested interpreters in multiple languages... Or writing code which runs in one "language" and then self modifies to another language which runs and subsequently self modifies, and so on.
I mean, does HN filter out PoC||GTFO release announcements or something? I seem to remember there being mention that it might've hit the filter list ..
My favorite time I had to do this was for a real-life situation. I wanted a script that was both a bash script (for speed) and a ruby script (if you installed it the default way).
I actually had use for a polyglot script at work, since in .csproj files, <PreBuildEvent> is run as a "batch" cmd script on Windows, but with bash on Linux. The simplest trick I could find was this:
rem () { ./bash-version.bash; exit $?; }
rem skip rest of script if executed by bash
rem batch script follows:
IF %blah% EQU 0 etc.
This is one of the vanishingly small implementations of fizz buzz posted online that don’t have separate paths for fizzbuzz cases than for fizz and buzz cases.