Explorations of Hello World Perversion

Posted by knorby on January 10, 2008 under Linux, Python, coding, humor, javascript | 6 Comments to Read

What follows is probably the most perverse shell script I have ever written. I decided to write a script that somehow implemented Hello World for a bunch of languages. I didn’t include Java, because the installation of java on the machine I wrote this script on was somehow messed up. Plus, Java sucks hard. I didn’t do any javascript either as Rhino was messed up (see last sentence), and spidermonkey wasn’t installed. I included far too many, but I will gladly add more if someone bothers to write some. You can also download the file. Wordpress messed a few things up, which I tried to correct, so download the file copy if you actually want to try thing thing out. Also, you might need to install some stuff unless you are in the UofC CS department Linux clusters. I apologize to the world for what my boredom can cause…


#!/usr/bin/env bash
#====================================
echo "Bash:"
bash << EOF
echo "Hello World!"
EOF
#====================================
echo "Python:"
python << EOF
print "Hello World!"
EOF
#====================================
echo "C:"
TMPFILE="/tmp/stupidgcc.c"
TMPOUTPUT="/tmp/stupidgcc"
touch $TMPFILE
cat > $TMPFILE << EOF
#include <stdio.h>
int main(){
printf("Hello World!\n");
return 0;
};
EOF
gcc -o $TMPOUTPUT $TMPFILE
$TMPOUTPUT
rm $TMPFILE $TMPOUTPUT
#====================================
echo "Ruby:"
ruby << EOF
puts "Hello World!\n"
EOF
#====================================
echo "Perl:"
perl << EOF
print "Hello World!\n"
EOF
#====================================
echo "C++:"
TMPFILE="/tmp/stupidg++.cpp"
TMPOUTPUT="/tmp/stupidg++"
touch $TMPFILE
cat > $TMPFILE << EOF
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World!" << endl;
return 0;
}
EOF
g++ -o $TMPOUTPUT $TMPFILE
$TMPOUTPUT
rm $TMPFILE $TMPOUTPUT
#================================
echo "Haskell:"
ghci -e 'print "Hello World!"'
#================================
echo "Awk:"
echo '' |awk '{ print "Hello World!" }'
#================================
echo "Fortran77:"
TMPFILE="/tmp/stupidFortran.f"
TMPOUTPUT="/tmp/stupidFortran"
touch $TMPFILE
#http://www.roesler-ac.de/wolfram/hello.htm#Fortran77
cat > $TMPFILE << EOF
C Hello World in Fortran 77
PROGRAM HELLO
PRINT*, 'Hello World!'
END
EOF
f77 -o $TMPOUTPUT $TMPFILE
$TMPOUTPUT
rm $TMPFILE $TMPOUTPUT
#=======================================
echo "Tcl:"
tclsh << EOF
puts "Hello World!"
EOF
#=======================================
echo "Octave:"
octave -q << EOF
printf("Hello World!\n");
EOF