At IHCC we were taught quite a few different languages which included C, C++, C#, VisualBasic .NET, COBOL, CICS, JCL, Java, PHP, and SQL. For a 2 year program that is quite a wide variety. After graduation I was hired as a COBOL developer and 2 short years later I transitioned to web development using Java and I also supported some VisualBasic 6 applications. During my stint with COBOL I was doing web development using the standard web stack (HTML, CSS, JavaScript) with PHP and Perl. Then I moved to a new employer and started using primarily Python and began a few side gigs using Ruby and PHP.
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:
- C (my code)
- Clojure (my code)
- CoffeeScript (my code)
- C++ (my code)
- C# (my code)
- Erlang (my code)
- F# (my code)
- Haskell (my code)
- Java (my code)
- JavaScript (Node.js) (my code)
- Perl (my code)
- PHP (my code)
- Python (my code)
- Ruby (my code)
- Scala (my code)
- XSLT (my code)
- Must print the nth number of the fibonacci sequence
- Must be a command line executable program that takes a single integer argument
- Must print the number from the fibonacci sequence that corresponds to the command line argument to stdout (including 0 so that given 5 the result should be 3, 6 should be 5 and so on)
- Must use recursion
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.
No comments:
Post a Comment