Polycode, an amazing piece of art!

As stated in the title i have truly came over an amazing piece of art:


Hit view source on that and stare at pretty strange,at the first look,source code. Well that source, my friends, is neither html, c, python or perl it is all of them, plus some more.The above linked source code compiles/interprets and runs under all of these languages: html+js, c/c++, python, perl, ruby, bash, sh, zsh, haskell, makefile, tcl and brainfuck.

I’ve tested the source on all of them just to make sure that it isn’t a joke and it isn’t! even if we count haskell which in my case it didn’t interpret (i used hugs but it didn’t work for some reason and i didn’t insist). Here is some proof output for the unbelievers:

shinnok@donkey:/tmp$ wget https://mauke.ath.cx/stuff/poly.html
–2009-01-21 18:26:11– https://mauke.ath.cx/stuff/poly.html
Resolving mauke.ath.cx…
Connecting to mauke.ath.cx||:80… connected.
HTTP request sent, awaiting response… 200 OK
Length: 2376 (2.3K) [text/html]
Saving to: `poly.html’

100%[======================================>] 2,376 –.-K/s in

2009-01-21 18:26:12 (2.21 MB/s) – `poly.html’ saved [2376/2376]

shinnok@donkey:/tmp$ python poly.html
I’m a Python program.
shinnok@donkey:/tmp$ perl poly.html
I’m a Perl program.
shinnok@donkey:/tmp$ ruby poly.html
I’m a Ruby program.
shinnok@donkey:/tmp$ cp poly.html poly.c
shinnok@donkey:/tmp$ gcc -o poly poly.c
poly.c:37:20: warning: trigraph ??! ignored, use -trigraphs to enable
shinnok@donkey:/tmp$ ./poly
I’m a C program (C89 with // comments, trigraphs disabled).
shinnok@donkey:/tmp$ cp poly.html Makefile
shinnok@donkey:/tmp$ make
I’m a Makefile.
shinnok@donkey:/tmp$ beef poly.html
I’m a brainfuck program.
shinnok@donkey:/tmp$ tclsh poly.html
I’m a tcl script.
shinnok@donkey:/tmp$ sh poly.html
I’m a bash script.
shinnok@donkey:/tmp$ zsh poly.html
I’m a zsh script.
shinnok@donkey:/tmp$ bash poly.html
I’m a bash script.

I find it amazing the way the writer of that piece of poly-code managed to use various syntactic and lexical as well as operators and language specific tricks in order to get that same piece of code to compile/interpret and run on all of those languages.

Tagged with:

2 Responses to “Polycode, an amazing piece of art!”

  1. fffff says:

    $ cp poly.html poly.lhs
    $ runhugs poly.lhs
    I’m a Literate Haskell program.
    $ whitespace poly.html
    I’m a whitespace program.

  2. Eileen says:

    Do you know where polycode has been moved to?

Leave a Reply