Friday, December 28, 2012

Seven Languages Week 1 - Ruby

I just completed the first chapter of Seven Languages in Seven Weeks which focuses on Ruby. On the assumption that the other six languages will follow the same pattern, the author divvied it up into three separate "days" (which was welcome as I'd been expecting 7 lessons which would dramatically lessen the chances of me completing any of these in a single week). The first lesson teaches the basic syntax of the language, the second lesson ties things together with more complicated structures, and at least in the Ruby chapter the third lesson was designed to show off "something cool" about the language - in this case, the metaprogramming facilities of Ruby.

I've had some minor experience with Ruby before, about the same extent that this book provided - the sort of introduction one gets over a couple of lectures or a 30ish page book chapter. As such it wasn't too confusing but we were definitely in the shallow end of the Ruby pool.

My first (err, second) impression of Ruby is that if one ignores Rails that there's not really any reason to prefer it over their favorite scripting language, e.g. Python, Perl, etc. I'm sure if a Ruby zealot was reading this they'd come up with a thousand reasons why I'm wrong but I simply can't imagine enough power existing in Ruby to warrant the sort of time investment it'd require for me to reach for Ruby first as opposed to something like Python (which I'm much more comfortable with) for scripting tasks, glue code, small apps, etc. Both are dynamically typed, object oriented languages featuring duck typing, metaprogramming facilities, functional programming trappings, etc. I'm sure one could spend all day describing how one tidbit was better in their favorite language in this fight but if I had to spend hundreds of hours achieving that level of fluency in the 'other language' it ain't worth it. And the last word on the silly Ruby vs Python debate that I just created - the Rubyists seem to love jumping up and down being sooo proud of "everything is an object!", which is something that always turns me off from a language (the zealots always spouting it, not that the statement is true).

All that said, what little I've seen of Rails was promising but this book didn't cover Rails at all. I have a fair amount of experience with Django (a popular web framework in Python) which was easy to use but Rails seems particularly easy to use and quick to develop on.

As promised, my solutions to the exercises (which could probably be gleaned from a google search) are available on my github account. I ran into a few minor road blocks - on Day 2 I spent a lot of time figuring that there had to be a much better solution, and on Day 3 I had misread the problem. Neither are really worth talking about here - after looking around on the web it seems that most people arrived at similar solutions (with varying degrees of proper Ruby idiom).

No comments:

Post a Comment