News for hackers. Stuff that matters.
Re:Code that is valid in both PHP and Java, and produces the... by alephnil on Thursday September 01, 2016 @01:44AM (#12403314)
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_Audienc...

It is both valid C, Pascal, COBOL, FORTRAN, Postscript, Bash, ksh and apparently also 8086 machine code (.com).

Re:Code that is valid in both PHP and Java, and produces the... by piaste on Thursday September 01, 2016 @03:50AM (#12403660)
Pretty 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.

Re:Code that is valid in both PHP and Java, and produces the... by Retric on Thursday September 01, 2016 @08:34AM (#12404745)
That'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.
Re:Code that is valid in both PHP and Java, and produces the... by ZoF on Thursday September 01, 2016 @04:20AM (#12403728)
Yep, I was expecting something different.
Re:Code that is valid in both PHP and Java, and produces the... by junke on Thursday September 01, 2016 @05:07AM (#12403861)
Re:Code that is valid in both PHP and Java, and produces the... by wangchow on Thursday September 01, 2016 @07:57AM (#12404534)
Hmm. Could use like 50 Lisp dialects to create the largest polyglot!
Re:Code that is valid in both PHP and Java, and produces the... by junke on Thursday September 01, 2016 @08:48AM (#12404814)
()
Re:Code that is valid in both PHP and Java, and produces the... by outsidetheparty on Thursday September 01, 2016 @09:02AM (#12404891)
Perfection
Re:Code that is valid in both PHP and Java, and produces the... by Grangar on Thursday September 01, 2016 @10:07AM (#12405318)
But... Why???
Re:Code that is valid in both PHP and Java, and produces the... by korethr on Thursday September 01, 2016 @02:21PM (#12407653)
Why 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.