learning

Ruby Foo

by Joey deVilla on May 30, 2011

ruby foo

After three years away from all but the most trivial of noodling with the Ruby programming language, I have become a Ruby Foo (as in Mr. T’s catchphrase, “I pity the foo’!”). I am severely out of practice with Ruby, and with two versions having appeared since I last made a living with Rails, even the act of creating a new project is completely different. Since Ruby is the preferred back-end programming language at Shopify and I am the Platform Evangelist, it’s time for me to “sharpen the saw”.

obie

Luckily for me, I ran into Obie Fernandez at the South by Southwest Interactive conference back in March. We sat down for a coffee and he told me about what was happening with Hashrocket and I told him that I was a hair’s breadth away from joining Shopify.

“I’ve been away from Ruby long enough that I’m probably back at newbie level again,” I told Obie between sips of latte made with overcooked beans. “I did it for a bit at the beginning using IronRuby, but between doing all the C# and PHP and the open source ‘Iron’ languages dying of neglect at Microsoft, I’m severely out of practice. I thinking of joining Shopify, and let’s face it: I don’t want to look like an ignoramus in the presence of rock stars like Tobi, Cody and Edward.”

“Give me your email,” said Obie, “and I can do something to help.” Of course he could – he’s the series editor of Addison-Wesley’s Professional Ruby series of books.

Shortly after South by Southwest, a couple of links to PDF editions appeared in my inbox. Thanks, Obie!

eloquent ruby

The first link was to Eloquent Ruby, Russ Olsen’s guide to speaking idiomatic Ruby and getting the most out of the Ruby programming language. It’s a breezy read, written in the same conversational tone that Olsen used in Design Patterns in Ruby, and the book is broken down into 31 bite-size chapters about a dozen pages in length. Each chapter’s title is some principle for programming eloquent Ruby – the first few are “Write Code That Looks Like Ruby”, “Choose the Right Control Structure” and “Take Advantage of Ruby’s Smart Collections” – and each explains that principle, provides code, shows you where you can find the principles used in actual, working projects. The book straddles the line between tutorial and reference; it’s written in tutorial style, but it’s organized so well that it might as well be a reference for those parts of Ruby that you might not use often (but should) as well as for those parts you keep forgetting (in my case, I always end up having to look up metaprogramming). I’ve been going through it at about a chapter an evening, and I’ve been getting smarter each time. Whether you’re coming back to Ruby after a hiatus like I am or if you just simply want to get better at Ruby, you should have this book in your library.

If you’d like to know more about Eloquent Ruby and its author, Russ Olsen, check out this interview with him at InfoQ.

ruby on rails 3 tutorial

I have yet to properly sink my teeth into Ruby on Rails 3 Tutorial but a quick scan of the book has shown that it’s quite promising, and the Amazon reviews are bolstering my belief.

I’ll be writing from time to time about my return to Ruby and Rails in this “Ruby Foo” series of posts, and I hope that whether you’re new to the language, returning after a break like me or aiming for “guru” status, that you’ll check out this blog regularly for notes on my explorations and what I’ve learned.

This article also appears in the Shopify Technology blog.

{ 0 comments }

Cover of

This article also appears in Canadian Developer Connection.

It’s easy to point to books on understanding and improving the inner workings of your code, the software and hardware platforms on which it runs and even the processes used in developing it. It’s much harder to find one on understanding and improving the programmer, or more specifically the programmer’s “wetware” – that is, the brain and mind. A few books aimed at programmers give a little space to the topic: Tog on Interface has a section and exercise on building your intuition, the first edition of Code Complete devotes a small chapter to character, and Cocoa Programming for Mac OS X reminds the reader that getting extra sleep when learning new material is essential. For a whole book on the topic, we’ve had to wait until Andy “The Pragmatic Progammer” Hunt’s Pragmatic Thinking & Learning: Refactor Your Wetware.

The first few chapters of PT&L form a quick introduction to the theories of cognition, learning and neuroscience on which the rest of the book is based. Among these are the Dreyfus Model, which explains how we progress from novice to expert and the steps along the way and a model of the brain in techie terms, shown below:

Diagram showing a "Dual core" model of the brain

Once PT&L has laid out these foundations, it dives into the brain-refactoring, including:

  • Taking advantage of R-mode (often called the “right brain” in pop psychology), which often gets ignored because of its non-linear, non-linguistic, unpredictable and even “artsy” nature. It’s actually an amazing problem-solver, so much that PT&L suggests that you should “lead with R-mode and follow with L-mode”, or more colloquially, “write drunk; revise sober”.
  • Working around the bugs in your brain. And there are many, from the primitive “lizard brain” that likes to override our higher cognitive functions to cognitive biases to generational affinity.
  • Learning deliberately: what learning is and isn’t, how to plan to learn, figuring out what your learning style is and how to best take advantage of it, and harnessing mind maps, documentation and teaching in order to learn.
  • Gaining experience, which includes understanding the importance of fun and how pressure kills cognition, learning the “inner game” and why your mantra shouldn’t be “learn to build”, but “build to learn”.
  • Managing focus, a very important topic since there are so many things vying for it, from office interruptions to the siren song of the internet, with email, IM, Twitter, Digg, Reddit and LOLcats. One of my favourite bits in this section was some research whose results indicated that constantly checking your email lowers your effective IQ more than smoking a joint.

PT&L does a great job following its own advice by presenting its material in ways that best take advantage of how our brains work, reinforcing its with anecdotes, metaphors and visuals and using the enjoyable style for which Andy Hunt’s other projects, such as The Pragmatic Programmer and his various training sessions have become famous.

As with any book that proscribes a new way of doing or perceiving things – think of books on Agile programming or “Getting Things Done” methodologies – you’ll have to pick and choose which ideas and techniques work best for you. In his review, O’Reilly editor Nat Torkington found the section on generational affinity a little too “Malcolm Gladwell”-ish in the way that it treats anecdotes about generations as data (personally, I think there’s some truth to the generational affinity thing). I do agree with Nat that some of the exercises, such as “Morning Pages” that seem a bit too new-agey/hippie even for me – and I’m the kind of guy who’d go to Burning Man.

This is the only book of which I’m aware that covers how to improve the tool that really develops code: not your platform, language or editor, but your mind. It’s worthy of several readings, first straight through and subsequent dives into specific sections. I took it with me on my flight from Toronto to TechDays Calgary and found it both not only informative, but engaging and entertaining as well. Best of all, barring some quantum leap in cognitive science that invalidates what we know today, PT&L will probably have a much longer shelf life than most of the tech books in your library.

It’s my favourite geek book of 2008.

Pragmatic Thinking & Learning is available in both dead-tree (US$34.95 direct from the publisher, CAD$30.69 from Chapters/Indigo online) and PDF formats (US$22.00). It’s a finalist in the “Books General” category of the 19th Annual Jolt Awards.

Would you be interested in hearing more from PT&L’s author, Andy Hunt, himself? Let me know either via email or the comments, and I’ll see what I can do about arranging an interview in some format with your questions!

{ 3 comments }

One lesson that Nathan Weizenbaum learned from Java that makes him a better Ruby programmer: “I learned what I was abstracting. I learned what blocks are, why dynamic typing is useful, what it means to redefine an operator. And I learned it from Java, by doing without.”

{ 0 comments }