How to learn Ruby - Tales in Rubyland part 1.

01 Jan 2011

Following the concept of learning a new programming language whenever I can as well as being curious about what changed in Ruby since I used it last time in 2003 as well as meeting Andy, I decided to go for it.

Preparation

Because you can write Fortran in any language, I first wanted to begin with engaging with the language’s mentality, it’s design. Because Ruby is being compared and sometimes competing with Python, I started with checking the web front and try to see how rails is designed VS django. A friend supplied me with the following old, but still great video: Snakes and Rubies (full)

</embed>

Also this vswiki entry somehow popped up.

First Steps

Thinking with my “old” brain, my first inclination was to buy a book, which I did, but while waiting for the book to arrive on my doorstep, I started realising that the whole ecosystem provided new innovative ways of learning.

Ruby Games

Say hi to Rails for Zombies. Rails for zombies is an interactive course where you learn how to program on Rails, by developing a twitter-like application for zombies :-). The game is arranged in levels and some additional goodies are available upon completion. It took about two days to finish it, by using only a modern browser. In order to support them the development team encourages the newcomer to buy a rails for zombies t-shirt. Would definitely buy something like a mug or stationary.

The book

In the mean time the book arrived: Head First Rails by being a long-term fan of the series. Armed though with the knowledge of having finished the game, the exercises got finished fast. What was tough was to do them o Rails3 which is not there by default nor in ubuntu or in os-x. In order to do so:

Having to fix something broken apart from the initial frustration is an experience that exposes the internals of the system under repair. This time it got used as an introduction to gems, the Rails command line and other details and idiosyncrasies of the community and the languages approach.

Going Deeper

Koans

After the first experiences the opportunity to dwell more into programming in the “Ruby Way” came with exposure to the Koans, quoting:

The Koans walk you along the path to enlightenment in order to learn Ruby. The goal is to learn the Ruby language, syntax, structure, and some common functions and libraries. We also teach you culture. Testing is not just something we pay lip service to, but something we live. It is essential in your quest to learn and do great things in the language.

Koans are essentially a list of tests that are designed to fail. The practitioner has to fill the gaps or write small chunks of code so that the tests will “pass”. Evaluation is being achieved by a simple:

 rake

while at the same time the 263 tests are a tour de force of all language’s features, conventions etc. At the end of the “challenge” you are being rewarded by a text adventure like screen (spoiler alert):

The experience and the layout of the tests was great. I only found the last one being a little bit more difficult than the usual case, which made me cheat a bit in order to solve it. The most surprising fact is that whenever I did not know which method to use, the most reasonable english word, did the trick.

Other Resources

Many and different and common. It seems that ruby programmers know them “by default”. I spent much time watching the rail casts, listening to the Ruby show. On the cheat sheet front, dzone’s reference card was great as well as envy labs rails3 cheat sheet, which makes most of the cheat sheets I’ve printed to look oh-so poor.

Conclusion

Great mentality, great language (I knew it would happen when I decided to write my dissertation on Ruby back in 2003, but would never expect it to be so big… never). Also great community. People are eager to accomodate the newcomer and teach the various ruby-isms which make things so great but overwhelmingly different.

Also having many issues solved because of the languages design and frameworks on top of it, code maintainers are investing huge amounts of time on code readability and maintainability.

Finally although Ruby is far more than that, most attention is on it’s web framework, Rails. So it is natural for most people to be a “web” language or a “php-killer”. I do not know if this limits languages reachability or if it is irrelevant.

Further steps

I suppose I will use it for a mini personal project that I can implement in any language that I want. Also I will do a Rails project whenever I have the chance. In part 2 the journey continues with Ruby’s scripting capabilities: Tales in Rubyland part 2.