[ Go back to normal view ]

BW2 :: the bitwise supplement :: http://www.bitwisemag.com/2

The Well-Grounded Rubyist
Book Review

18 July 2009

by Huw Collingbourne

The Well-Grounded Rubyist
$44.99 Softbound print book - (includes free ebook)
by David A. Black
Manning http://www.manning.com/black2/
520 pages
ISBN: 1933988657



Just when you thought there were already so many books on Ruby that there could surely be nothing more to be said on the matter, along comes Ruby 1.9 - and changes everything...

Well, OK, maybe not everything - but the differences between Ruby 1.8 (currently Ruby 1.8.6 is probably the closest we have to a ‘standard’ version) and Ruby 1.9 are significant enough to require some re-learning and re-coding. And that’s where David A. Black’s book, The Well-Grounded Rubyist, comes to the rescue.

The books covers pretty much the range of topics that you would expect from a work that aims to introduce programmers to the Ruby language. If this is your first dip into Ruby, it will guide you through all the basics of variable declarations and method-calling syntax, defining classes and creating objects from them. Later chapters cover specifics of the Ruby class library with chapters such as ‘Collection and container objects’ and ‘Regular expressions and regexp-based string operations’. There is also a section devoted specifically to dynamic features of Ruby including metaprogramming and object introspection.

It has to be said that most of these topics - and the coding syntax used - are equally applicable to Ruby 1.8.6 and Ruby 1.9.1. There are, however, a few tricky areas in which the differences between Ruby versions may have profound effects on the behaviour of your code (a notable example is the behaviour of block parameters). Unfortunately, the author deliberately avoids listing the differences between Ruby 1.8.x and 1.9 (“I don’t make any attempt to catalogue the changes in this book,” he says, “Doing so would expand the book enormously and, ultimately, wouldn’t work.”). Instead he recommends Googling for lists of the changes. Personally, I think this decision is unfortunate since for anyone with existing Ruby 1.8 experience the first thing you want to find in a book on Ruby 1.9 is a list of differences so you can immediately focus in on them.

Another thing you need to be aware of is that, in spite of its name, The Well-Grounded Rubyist is, in large part, an adaptation of David Black’s previous book, Ruby For Rails or ‘R4R’. There are, of course, many differences in the new book, the most obvious of which is the lack of coverage of Rails and correspondingly more in-depth coverage of Ruby. In his introduction, Black describes the new book as “a descendent of R4R but not exactly an update. It’s more of a repurposing”.

Be that as it may, if you already own a copy of Ruby For Rails you may feel that there is enough duplication in the two books to make the new book somewhat less than an essential purchase. Let me give you an example. This is paragraph one of Chapter 6, ‘Control-flow techniques’ in The Well-Grounded Rubyist and Chapter 8 in ‘R4R’:

“As you’ve already seen in the case of method calls - where control of the program jumps from the spot where the call is made to the body of the method definition - programs don’t run in a straight line. Instead, execution order is determined by a variety of rules and programming constructs collectively referred to as control-flow techniques.”

And so it goes on. The text of this and other chapters is not identical in the two books - but there are many close similarities.

Overall, this is a pretty decent introduction to Ruby programming. In fact, I prefer it to its predecessor, ‘Ruby For Rails’ which, I felt, tried to cover too much ground thereby compromising the clarity of the explanations. Its concentration on Ruby 1.9.1 does make it rather a ‘specialist’ book, however. On the one hand, it is a rarity, since few Ruby books have much to say about Ruby 1.9; so, if Ruby 1.9.1 is the version you plan to use, this would be a great book to buy. On the other hand, the plain fact of the matter is that there are so few books on Ruby 1.9 because relatively few developers are using that version. Ruby 1.8.6 remains the ‘Ruby of choice’ for most people and while it is, in principle, possible to run Rails on Ruby 1.9, this is not without problems (see the Ruby On Rails Guide note on Ruby 1.9.1 compatibility).