7 ms·
When reading this, I remember that while I was studying computer science back in the early 90s, such programs was known as "polyglot" programs. One such example
by alephnil 10y ago
When reading this, I remember that while I was studying computer science back in the early 90s, such programs was known as "polyglot" programs. One such example that circulated on email and usenet groups back then had at least 6 programming languages. After a bit searching I actually found back to that program:
http://www.csd.uwo.ca/~magi/personal/humour/Computer_Audience/polyglot.[cob|pas|f77|c|ps|sh|com].html http://www.csd.uwo.ca/~magi/personal/humour/Computer_Audienc...
It is both valid C, Pascal, COBOL, FORTRAN, Postscript, Bash, ksh and apparently also 8086 machine code (.com).
- piaste 10y agoPretty disappointing that it relies so much on comments. You can write an arbitrary 'polyglot' program in any N languages that have incompatible comment delimiters: just write the same program in each language and wrap it in the comment delimiters of the other N-1 programs. That's not interesting, though.
- ZoF 10y agoYep, I was expecting something different.
- Retric 10y agoThat's not enough, if you start with language A's escape sequence /* that must not break languages B, C, D, E or F when starting a file with /* next B's escape sequence must not cause problems with C, D, E, or F. So, they must be different but still compatible.
- junke 10y agoSee also https://codegolf.stackexchange.com/questions/tagged/polyglot https://codegolf.stackexchange.com/questions/tagged/polyglot
- wangchow 10y agoHmm. Could use like 50 Lisp dialects to create the largest polyglot!
- junke 10y ago()
- outsidetheparty 10y agoPerfection
- Grangar 10y agoBut... Why???
- korethr 10y agoWhy not? Sometimes pushing against the boundaries of what can/can't or should/shouldn't be done is entertaining, educational, or both. I mean, why would you abuse the spindles and armature in a hard drive to walk it across the floor like a poorly balanced washing machine, make a Unix clone for your 386, turn the Green Building into a Tetris game, write a Brainfuck interpreter in TECO, or run Flappy Bird on a Super Nintendo by exploiting bugs in Super Mario World? Seriously, what kind of right thinking person would engage is such perverse, time-wasting silliness? ;) See above.