Developer

Review: The Ruby Programming Language lacks real-world code examples

Justin James is disappointed that the authors of O'Reilly's The Ruby Programming Language didn't prepare him to write a real application. Read his book review for more details.

 

Regular Programming and Development readers may recall that I first started talking about learning Ruby in the latter part of 2008. As part of my plan, I picked up a copy of O'Reilly's The Ruby Programming Language by David Flanagan and Yukihiro Matsumoto (the "inventor" of Ruby, who is often called Matz by people in the Ruby community). I selected this book based on the fact that Matz is a co-author; I felt this would be a guarantee of accuracy if nothing else.

Overall, I was disappointed in this book. It started strongly; I rolled right through the first few chapters, and I learned a lot of new ideas and concepts. Then, I hit a brick wall; the content suddenly felt much less like reading a book that was walking me through a complex topic to one that was throwing me to the wolves. I went from devouring a few sections a night to not opening the book for weeks at a time. The last few chapters are so dryly written that I felt like I was reading a reference book rather than an educational book.

The first portion of the book shined. The authors explained a lot of really useful things, such as what kind of naming conventions are considered "standard" in the Ruby community, and provided details about why you should do something one way instead of another. I look for these types of things when I turn to a book; I can find out basic syntax, function, and library reference materials just about anywhere.

But, somewhere in the discussion about enumerators, the thread was lost. The discussion of this topic (which is so crucial to properly understand and efficiently use Ruby) was muddled at best. At first, I understood what was going on, but then over the course of a few pages, I no longer understood the conversation. From that point on, much of the book relied entirely too much on "documentation by example," in which a series of code statements operating on an object or two were shown, with the result of each statement shown. The authors didn't explain why I would choose to do certain things or how to get from point A to point B in common code situations. In other words, the book suddenly became a basic library reference.

It was also extremely annoying and confusing how the authors handled the differences between Ruby 1.8 and Ruby 1.9. From what I gathered, Ruby 1.9 probably should have been called Ruby 2.0, as it contains some major changes from Ruby 1.8. In addition, it seems like those changes are often not backwards compatible, leading many in the Ruby community to not upgrade to Ruby 1.9. As a result, the authors try to discuss both versions and highlight the differences between the two versions. I had no interest in looking at the Ruby 1.8 stuff, since I assume that for new development, I would want to use Ruby 1.9, but I may be mistaken. Regardless, not only were the differences laid out in a way that made it easy to get the two versions confused, but in many cases, it was unclear as to why Ruby 1.9 would be an improvement at all.

Finally, other than a great Sudoku example near the beginning of the book, I never got a sense of building an application with Ruby. The Sudoku example actually got me hooked; I imagined writing the same application in C# or VB.NET, and I immediately saw the power of Ruby. But the authors never showed me what any Ruby code would feel like in real-world usage, not even standard set-piece scenarios like a CD collection organizer or a to-do list application. In fact, the authors are so focused on the features of the Ruby language and nothing else that they don't even discuss XML processing or database access — two topics that are critical for the vast majority of real-world programmers.

O'Reilly publications tend to be accurate, and Matz' involvement should be a guarantee of it. Outside of that, there is little to recommend in this book. I probably know Ruby as a language fairly well now without having ever used it, but I don't think that my time investment prepared me to write a real application.

If you have a different opinion of this book, I would love to hear it — please post your feedback in the discussion. Also, if you've read any Ruby books that you recommend, share those titles with the audience.

Ruby resources from TechRepublic

J.Ja

Disclosure of Justin's industry affiliations: Justin James has a working arrangement with Microsoft to write an article for MSDN Magazine. He also has a contract with Spiceworks to write product buying guides.

———————————————————————————————————————————-

Get weekly development tips in your inbox Keep your developer skills sharp by signing up for TechRepublic's free Web Developer newsletter, delivered each Tuesday. Automatically subscribe today!

About

Justin James is the Lead Architect for Conigent.

Editor's Picks

Free Newsletters, In your Inbox