Clinton Montague

Developer, learner of things, functional programming enthusiast, hacker, and all round inquisitor.

Reflections on a week with Ruby

June 18, 2011

Well, my date with Ruby is almost over. Tomorrow, the 7 languages in 7 weeks study group moves onto Io.

I’ll tell you what though, I’ve learnt more about Ruby, it’s syntax, and how it generally feels to use in the last couple of days than I had done while attempting to learn it before. It’s much easier to learn under pressure, when there’s a challenge than when you just want to learn it for fun.

I think that one of the biggest challenges for the coming weeks will be getting to grips with how each of the languages looks and smells like. Sure, a block in Ruby is quite a simple thing to get grips of, but without practice and being used to what the code looks like, it’s not second nature. And the rapid switch between different languages will be sure to keep me on my toes.

Having said that, my relationship with Ruby is not over. I’m extremely glad that I had the opportunity to really get to know it. It’s great fun to use, extremely concise, and I can see how it ultimately makes you a more efficient programmer. I can see why people get obsessed with it, and why so many PHP programmers end up switching to Ruby, it really does make programming fun again!

I’d like to have had a little more time to get to grips with the (what to me feels like a lack-of) syntax, but because I joined the study group a couple of days after it started, I’m not going to feel too bad about it. I’ll give myself a couple of extra days to play with it until I feel that it’s really sunk in.

I really like the way that it cuts the crap and lets you go onto describing what you want to say, rather than having to concentrate on the minor things in life like closing a file or needed to use hundreds of braces. I used to think that languages like this were for people who didn’t understand programming; it turns out that the more you understand programming, the more a language like Ruby just makes sense.

I’m also really pleased with how much I’m playing around and learning. The author describes it as releasing the inner n00b – that’s the perfect description. As a n00b, you’re not scared of just trying stuff out. As a professional, you’re more inclined to be ‘scared’ of doing something wrong. With a set of seven languages that I really have no experience of, my inner n00b is going to be most happy with what’s to come. I can already see improvement in my code from just today’s work; one of the exercises in the book is to print the numbers from 1 to 16 in groups of 4:

# create an array with a range - magic!
a = (1..16).to_a

# first attempt
a.each_slice(4) do | slice |
	slice.each do | item |
		print "#{item} "

# by the end of the day, it was an elegant one-liner
a.each_slice(4) { | slice | puts slice.join(' ') }

I’ve still only completed 2 of the 3 days’ work on Ruby so far. The next day involves meta-programming. That sounds like proper fun! I’ve been playing with Ruby all day now though, so probably time to put it down and get some rest ;) Will play with Day 3’s exercises in the morning before my first skype catch-up to see how the rest of the group has been doing and to compare notes so far on Io.

Can’t wait for tomorrow to see what Io brings and to see what other lessons about programming philosophy that I’ll learn!