My journey through these seven different programming languages starts with a language I am already familiar with: Ruby. Even so the chapter was an interesting read and provided some new background information.
The character that Bruce chose to represent Ruby is Mary Poppins, the British nanny. With a spoonful of sugar she made the household more efficient by making it fun. Ruby does the same thing to programming, with more than just a spoon of sugar. Syntactic sugar. These little language features break the basic rules of the language to make the code a little easier to understand.
The creator of Ruby, Matz (Yukihiro Matsumoto), doesn’t worry much about the runtime efficiency, he optimizes Ruby for programmer efficiency. He makes the language simpler to read and to program in by adding more complexity on the parsing and interpretation side.
Ruby is a strongly typed dynamic language. Dynamic type systems rely on duck typing, where the features of an object are based on what it can support rather than its class hierarchy. Duck typing, in general, will gain you cleaner abstractions with more concise, readable code. The cost of duck typing is less comprehensive tool support (e.g. the IDEs for static languages). The fact that Ruby is a very dynamic language is proven by its extensive support for meta-programming.
The book provides some nice exercises to get hands on with Ruby, like writing a number-guess game, a basic grep implementation, and an interesting API to the information from a CSV file using meta-programming. I put my solutions to these exercises in the 7-languages-in-7-weeks repository on my Gibhub profile. The rest of the exercises from the book where much smaller and more trivial. I did these in the Repl [Read-eval-print loop].
The strengths of Ruby lie in its pure object orientation. Ruby is a great language for web development. Because the language is so productive it is awesome for bringing a viable product to marked quickly. Ruby is also ideal for scripting since it is present on most major operating systems.
The main weakness of Ruby is its runtime performance. Some major performance improvements have been done in Ruby 1.9 and there are some attempts at bringing JIT compilation to Rubinius. And as with any object oriented language the programming model also is a weakness. It depends on the idea of wrapping behavior around (usually mutable) state. This model often leads to serious concurrency problems, that are almost impossible to test and debug.
As I mentioned at the beginning of this article, Ruby and I have met before. In fact, Ruby is one of my favorite languages at the moment. After the long ruling of languages from the C family it’s a breath of fresh air. It’s syntactic sugars help you to write very clean and readable code.
Time to continue my travel to the destination for next week: Io.