I went to college at Indian Hills Community College in Ottumwa Iowa, which I do not regret in the slightest. The Software Development program was outstanding and I’m actually fairly impressed by how the curriculum changes over the years. During my time there, one class in particular really stood out as the one class that taught me the most. This class was called “Language Exploration”. The syllabus was simple, take a program that you wrote for one of your other classes and re-write the exact same program in 3 different languages. The reason why I thought this class was the one that I learned more from than any other was because this was one of my first experiences with learning new languages on my own. In this class I basically taught myself how to teach myself new languages.
I’ve always enjoyed learning new languages. When I’ve moved from project to project there are certain things that get lost. After using Python for a while and not looking at any Perl code, going back and looking at Perl’s data structures takes a few minutes to wrap your brain around (with all of the referencing/dereferencing). Moving between Java and Ruby is difficult because of semi-colons and return types. There are a million different reasons why switching back and fourth between different languages can cause trip-ups.
These little trip-ups are the reasons why I wanted to create a repository dedicated to language comparison. I wanted to recreate my experiences in the language exploration class on a larger scale. Instead of the class’s 3 languages I decided to go with 16. My first task was to choose languages. I started with languages that I know, and languages that I’ve dabbled in then I added a few others that I’ve heard about but never really used. I decided to cap it at 16 languages for no real reason other than that is how many languages that I came up and seventeen just seemed like too many and fifteen just didn’t seem like enough.
The languages are as follows:
With a list of languages to work with, my next task was to write a “Hello World” in each of them. I opted to limit that to “Hi”. So I wrote 16 programs that printed “Hi” to stdout, one in each of the above languages. That was pretty simple, so I decided to take on a slightly more challenging task. Here are the guidelines that I started with.
That took a bit more time. Truthfully, the fibonacci sequence is fairly easy to implement using recursion in any of these languages. The hardest part was figuring out how to parse command line arguments and convert it into an integer. Erlang seemed to give me the most trouble here, in the end the solution was not all that difficult, I just had to figure out what it was which ended up taking a lot of time. XSLT was sort of a special exception rather than accepting the number from the command line it was parsed from an input xml file.
My long term goal is to continue to add new simple examples that show how a problem can be solved in each of the 16 languages, and hopefully I will be able to demonstrate some advantages that some languages provide over others.
If you care to browse the examples, please do https://github.com/mattjmorrison/polyglot. Also, I am absolutely not an expert in all of these languages, so if you are and you have some tips for me please submit a patch.