Three Breaths

Musings on code, management, and life

So Begins The Season of Ruby

Posted at — Jan 18, 2012

I wasn’t sure if from my last post, this would be a year of Ruby, a lifetime of Ruby, or 20 minutes of Ruby, so let’s start with the notion of a season of Ruby.

Lao Tzu said “a journey of a thousand miles begins with a single step”.  So as much as I would like to embark on this voyage on a shiny new Mac, running TextMate as my editor, I will stick a little closer to my comfort zone and start out running RubyMine on my Windows machine.  As a .NET developer, I am pretty entrenched in the IDE experience.  That is not to say I don’t want a shiny new Mac, but I also don’t want to get bogged down as I learn a new language.  The RubyMine experience is very familiar to me since I use Visual Studio with Resharper and for a mere $69 for a personal license it seems like a no-brainer.

So where to start….

I scoured various blogs and the Ruby docs for good places to learning Ruby.  I settled on starting with the Ruby Koans site.  I really like that this tutorial had a test-centric approach.  One of the draws to exploring the Ruby community is that testing is baked into the culture.  The Ruby Koans allowed for a lot of experimentation and I tried to take the approach of not just blowing through the problems, but really asking what are they trying to teach in this lesson.  I tried to cause tests to fail in different ways and added some scenarios of my own to try and investigate further.

Another resource was to just use IRB, the interactive Ruby shell.  Nil is an object, huh?  What methods does it have.  I suppose I could pore through documentation or maybe just…let’s see if this works

irb(main):001:0> nil.methods
=> ["inspect", "&", "clone", "public_methods", "display", "instance_variable_defined?", "equal?", "f
reeze", "to_i", "methods", "respond_to?", "dup", "instance_variables", "__id__", "|", "method", "eql
?", "id", "to_f", "singleton_methods", "send", "taint", "frozen?", "instance_variable_get", "^", "__
send__", "instance_of?", "to_a", "type", "protected_methods", "object_id", "instance_eval", "==", "=
==", "instance_variable_set", "kind_of?", "extend", "to_s", "hash", "class", "tainted?", "=~", "priv
ate_methods", "nil?", "untaint", "is_a?"]
irb(main):002:0>

Good gravy, so simple even a .NET developer like me can do it ;)  I found myself playing a lot in the IRB when I wanted to just try something out.

I got though the basics of asserts, objects, nil, and arrays with the koans, diving over to various websites, StackOverflow, irb, and the Ruby core docs as I ran into questions.  I am using the Pomodoro technique to timebox my activities into manageable chucks and try to stay fresh.

The plan for next time will be to continue with the koans, probably for a while, to build up some core knowledge.  At some point I will dive into the Koans code itself as one of the goals of the last post was to read more code as well as write it.

In my experience, the best way to learn code is to write code, but I also reserved the following books from the library to have around as  references and for tips on style.

I also want to take a peek at Why’s (Poignant) Guide To Ruby

comments powered by Disqus