Russ Olsen has just come out with a wonderful book on Ruby called Eloquent Ruby. If you're a Rubyist, you should get it. What's great about it is that it combines a breezy, even sometimes funny, style that is "teacherly" but also accurate in matter of detail.
There are a couple of things that really make the book work. First, there's a nice little
Document class that Olsen bends this way and that, using it as the vehicle for explaining subclassing, modules, mixins, and metaprogramming. My first impression was that it was a little lame, but by the end of the book I was very impressed with the range of examples. Indeed, the use of a Document class reminded me of some of the class examples from the Gang of Four book.
A second fine feature is that there are many sections devoted to a particular topic "In the Wild." We have needed this in Ruby books for a long time -- a coupling between Ruby as we know it in a textbook, and Ruby in the real world. These are really quite different "Rubies," but Olsen is adept at showing through sometimes-simplified examples that the occasionally imponderable real-world Ruby really does share an idea of code with what learners start with.
I also like the chapter near the end of the book on the various Ruby interpreters, and how you can get something out of reading the code, be it in C, Java, or Ruby.
Now, about teaching Ruby.
Ruby is a tough teach. Students plateau at an average level of competence quickly, but the real power of Ruby comes after a stiff hike up the mountain to enlightenment.
I used to think that one could use the Programming Ruby book alone, and this would do the job. But it's long, and in its new edition somewhat hobbled by not discussing Ruby 1.8.x. In a number of places there is discussion that seems aimed at Java developers (see how easy it is in Ruby!) that feels out-of-date to me now.
But having read Olsen's book, I'm now thinking that a better sequence is to pair Cooper's Beginning Ruby with Eloquent Ruby, supplemented, perhaps, with the Flanagan/Matz The Ruby Programming Language. This way, you get to be effective and productive quickly (via Cooper), wade into the depths and improve your style (Olsen), and get the final word on syntax and semantics (Flanagan/Matz). A place where I think Programming Ruby may still have the edge is in some of the metaprogramming discussion, but here I think the best resource out there is Thomas's video series.comments powered by Disqus