Apparently, the following code compiles in ten different languages (shell scripting included)! The cool part is that it produces different output in all of them. Can someone verify this? The languages are C, C++, Perl, TeX, LaTeX, PostScript, sh, bash, zsh and Prolog.
Of course, hats off the the original coder!! %:/*:if 0;"true" +s ||true<</;#|+q|*/include<stdio.h>/*\_/
{\if(%)}newpath/Times-Roman findfont 20 scalefont setfont(
%%)pop 72 72 moveto(Just another PostScript hacker,)show((
t)}. t:-write('Just another Prolog hacker,'),nl,halt. :-t.
:-initialization(t). end_of_file. %)pop pop showpage(-: */
int main(){return 0&printf("Just another C%s hacker,\n",1%
sizeof'2'*2+"++");}/*\fi}\csname @gobble\endcsname{\egroup
\let\LaTeX\TeX\ifx}\if00\documentclass{article}\begin{doc%
ument}\fi Just another \LaTeX\ hacker,\end{document}|if 0;
/(J.*)\$sh(.*)"/,print"$1Perl$2$/"if$_.=q # hack the lang!
/
sh=sh;test $BASH_VERSION &&sh=bash;test $POSIXLY_CORRECT&&
sh=sh;test $ZSH_VERSION && sh=zsh;awk 'BEGIN{x="%c[A%c[K"
printf(x,27,27)}';echo "Just another $sh hacker," #)pop%*/
-Source: http://weblog.raganwald.com/2006/12/just-because-we-can.html
A random collection of things I come across.
Saturday, February 24, 2007
Multi-lingual code!
Posted by Prashanth. at 2:29 AM
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment