7 Languauges - Ruby

Myself and a few colleagues are working through Seven Languages in Seven Weeks We've just completed week 1 - Ruby.

I still can't make up my mind about Ruby. At first I really liked it. The syntax looked clean, no semi-colons or braces, being able to omit parentheses when calling functions with a single parameter etc. I also liked all the array methods that accept blocks (essentially functions) that allow mapping and filtering etc. I even liked the one-liner conditionals using 'unless' or 'if' which seemed to me concise and expressive. My notes show that the only minor quibbles I had after day 1 were 0 being truthy and "elsif" missing an e - I can accept elif, elseif and else if, elsif is weird :)

After day 2 and 3 there were more things I liked. In many ways I appreciated the openness of the language, that everything was so easily accessible to the programmer, such as the supported methods on an object or even its object_id, and the consistency of "everything is an object" philosophy. The meta-programming possibilities in Ruby look great, and along with the ability to bend the syntax with things like method_missing make it seem like a great language for writing a DSL. Another thing I liked about method_missing was that it serves to emphasise the message passing semantics of calling object methods, which is perhaps easy to forget in other common OO languages.

Despite all this, I didn't find myself really warming to the language. I think perhaps the highly dynamic nature, the syntactic sugar, the multiple ways of expressing things and not too mention the sheer size of some of the standard classes 1 made the language feel a bit less coherent than others I have tried. I think I have a 'less is more' preference for programming languages. To me smaller languauges seem a bit more elegant, though I appreciate that they can appear less 'readable'. In fact, that reminds me of a little rant I need to have about what readability means but that can wait for another blog post :)

Anyway, Ruby, it was nice to meet you again, but I think you'll remain just a passing acquaintance. It's time to go an introduce myself to IO!

  1. String.methods.size returned 81 in the version of Ruby I was running, which I think is around twice the number of string methods in JavaScript. On the other hand, I suppose it was pretty cool that I could find that out so easily - I had to look in the Mozilla docs for JS :)