How I’m learning Ruby
Ruby is a tough language to learn for a C# developer. There, I said it. There are quite a few fantastic books out there that will really help you learn this awesome language, but it’s still a difficult language to learn. If you’re used to having IntelliSense and using Resharper all day it’s a difficult adjustment to make.
While reading a guide such as the Pickaxe book from cover to cover will eventually teach you some Ruby programming, I usually get too impatient. I usually want to start writing something small as soon as I know the syntax. This blog from Mike Clark finally tipped me over the edge – he advocates learning by writing simple tests and it works really well.
Where to start
Mike Clark introduces the idea of maintaining a suite of tests – you build the tests to try out different language and syntax features. I find this to be a great way to learn Ruby – if I’m simply reading out of a book I tend to forget certain features and I’m forced to go back and re-read certain parts. With the suite of tests I can simply go back and look at my tests – it works really well.
I found a great way to start is to implement a few simple algorithms – bubble sort, binary search, etc. If you’re looking for inspiration a great idea is to look for programming interview questions – from the ridiculously simple to the really advanced questions.
Here are a few of the questions I’ve gone through so far:
- Reverse the order of the words in a sentence – try doing it with and without the reverse function
- Binary search
- Bubble sort
Ruby Koans
Mike Clark’s blog post was the inspiration for Ruby Koans – a suite of broken tests which you need to fix. It’s a fantastic way of learning Ruby – you learn the syntax and different language features in an incremental fashion and in the end you’re left with a complete set of tests as a language reference.
The tests will even give you some Zen-like advice on every run – the authors clearly have a great sense of humour and it really makes the whole learning process a lot of fun.
Project Euler
Project Euler is a series of challenging mathematical/computer programming problems that will require more than just mathematical insights to solve. While the original purpose of Project Euler is to provide a platform for inquisitive minds to learn new concepts in a fun context, it also provides a great platform for learning a new language. Simply run through the different problems in your language of choice and you’ll be well on your way.
Conclusion
Do you have any tricks for learning Ruby? If you do, leave comment below. Happy coding.