After a tough day in the office you want to catch up on the news, so you look at the ticker on a TV channel or tune in your car radio. Other days you’ll want to sit down with a meaty broadsheet and really take in the detail of what lies behind the headlines. This is a book about Ruby which which triumphs at walking the line between these two styles. The Well Grounded Rubyist aims to appeal to a developer that has been exposed to some Ruby coding and take their knowledge to the next level. And it succeeds brilliantly.
This is not a book about Rails or any other web frameworks; purely Ruby. Though much of the material will also apply to the 1.8.x series of Ruby, this is a book about the 1.9 version of the Ruby language. It’s broken into three parts - Ruby foundations, Built-in classes and modules and finally Ruby dynamics. But don’t let the title of Ruby foundations fool you for part one - this is not some remedial rush through the basics of Ruby in six chapters. Rather, after a couple of warm-up chapters, it moves quickly to clarify the key aspects of how classes and module inter-relate, as well things such as crystallising what ‘self’ really means in different contexts in a Ruby program. The author sets out his stall early - what makes Ruby different from other languages is it’s focus on objects rather than classes. Everything else stems from this and by the end of the section you feel like you have an understanding of Ruby’s design and focus.
Part two of the book is Built-in classes and modules. Now that you know what makes Ruby tick, it’s time to get seeped in all aspects of the core library that ships with it. One of the problems when learning a language is that becoming familiar with all methods of a particular core class is a tedious task. It’s much more interesting to learn about concepts such as meta programming than memorising lists of methods by rote. But if you don’t take the time to familiarise yourself with the dusty corners of a language’s API then you’re less likely to think of those handy methods when a problem they would elegantly solve presents itself. At this point the book shifts gear to a more reference style of text. However, it still gives the reader an interesting story to follow as it documents arrays, hashes and other classes - throwing in the occasional golden nugget of information that will be a valuable additional to the toolbox of even experienced Rubyists. One side effect of the change in style is that this section is probably the most accessible to beginners. Again it’s broken down into six chapters. In addition to collections, it also covers topics such as regular expressions and file handling. Each topic takes a zero-to-hero approach meaning that you can bring little regular expression knowledge to the table yet still walk away learning an immense amount about the subject.
The final part of the book, Ruby dynamics, returns to the book’s roots from part one - a focus on imparting a deep knowledge of Ruby’s design. Before you even pick up this book you have an inkling that procs and lamdas are going to make a guest appearance at this late stage. And they do not disappoint. Extending the behaviour of objects takes centre-stage and meta-programming based techniques move quickly to the fore. Any block/proc/lamda confusion you may have will be a distant memory by the time you finish this section. Threading is also covered here - though a detailed discussion of 1.9’s new native OS threads vs green threads is left to one side to focus on the usage of threads regardless of which underlying type you use. Lots of material is also provided on querying objects; which is not only useful for program design but also invaluable as a debugging aid. The book really shines in this section because a lot of other texts make the mistake of going into ‘super-boffin’ mode at this point, leaving the reader lost, whereas the author here continues to provide patience and context to get you round that final lap on you way to becoming a Well Grounded Rubyist!
This book cannot be all things to all people. Because it is catering for a wide range of intermediate to advanced Rubyists, it will feel like it’s moving a little too slowly for some. By the author’s own admission, this is in order to make it accessible to a wider audience and no doubt it will make it easier for developers of all levels to digest - your humble reviewer very much included! Ruby first-timers would be best off having some straight-to-the-point tutorials or entry-level text to hand in order to get some instant gratification - as part one of the book, by it’s very nature, is a little more abstract than a complete beginner would expect. But all in all, this book is a great way to learn just how Ruby crams so much expressiveness into such a simple clean framework. Whenever I read a book like this I keep a list of new things learned along the way. For The Well Grounded Rubyist it is a very long list! Well done to David A. Black and Manning for producing a book that fills those gaps in many Rubyists’ understanding of the language while at the same time delivering an absorbing readable book that would sit proudly on any Ruby programmer’s bookshelf.