Articles / The Ruby Way

The Ruby Way

Many Ruby programmers learned the language from Andrew Hunt and Dave Thomas's excellent "Programming Ruby: The Pragmatic Programmer's Guide". For over a year, it was the only English language Ruby book available. Now, Hal Fulton's "The Ruby Way" comes at just the right time for those of us ready to move up to the next level.

I have to admit that I usually don't read Introduction sections of programming books, but I actually found this one to be informative. In it, the author sets forth two main goals for the book: to illustrate "The Ruby Way" (Ruby's philosophy) and to answer questions in the form of "How do I accomplish some task in Ruby?". The first goal, he admits, is something that the reader will mostly have to get by actually using the language, and I can concur with that sentiment. He also points out that this is not a book intended for learning Ruby. However, I think that an experienced Python or Perl programmer (if the latter is familiar with object orientation) could actually pick up this book and learn a lot of Ruby from it, though she would probably also want to purchase either Programming Ruby: The Pragmatic Programmer's Guide or Ruby in a Nutshell as a reference to Ruby's built-in libraries.

Chapter 1, "Ruby in Review", introduces the basics of the language. This is a must-read section for those who are new to Ruby, though I found that I learned some things in the section "Rubyisms and Idioms", even though I've been programming in Ruby for over a year.

The cookbook portion of the book begins in Chapter 2, "Simple Data Tasks". Accomplishing various tasks with String, regular expression, Number, Time, and Date types is explained here. Don't let the "Simple" in the chapter's title mislead you, though; there are some fairly highlevel concepts discussed here, including "Calculate the Levenstein Distance Between Two Strings" and "Numerical Computation of a Definite Integral". I must admit that I hadn't heard of the "Levenstein Distance" before, so I learned something here.

Chapter 3 deals with more complicated data structures: the built-in Array and Hash types, Stacks and Queues, and Trees and Graphs.

Chapter 4, "External Data Manipulation" covers "Working with Files and Directories", "Performing Higher-level Data Access (serialization)", and "Connecting to External Databases".

Chapter 5 deals with "OOP and Dynamicity in Ruby". Again, I found that I learned some things in this chapter, especially in the "More Advanced Techniques" and "Creating Parametric Classes" sections. Some of these techniques are not covered in any of the other English language Ruby books that I've seen, and until now, the only way you might have learned them was by lurking on comp.lang.ruby.

Chapter 6, "Graphical Interfaces for Ruby", covers the creation of GUIs using three GUI bindings: Tk, GTK, and Fox. It's a nice introduction to the topic, but certainly not an exhaustive treatment. It would have been nice to have some coverage of the Qt toolkit, which is also available for Ruby. Readers looking for a more in-depth treatment of GUI toolkits will need to look elsewhere, but that's not a big surprise from a book that strives to cover so many topics.

Chapter 7 covers Ruby's cross-platform threads and includes several examples. Several different ways of synchronizing threads are presented.

Chapter 8 is perhaps one of the most practical chapters in the book. System administration issues are covered, including running external programs and process manipulation. Again, I learned something new: I didn't know about the existence of the Shell library before. There is also a section on scripting in the Windows environment for those who need to do cross-platform scripting.

Chapter 9, "Network and Web Programming", covers a lot of ground: SMTP, threaded servers, mod_ruby, e_ruby, the CGI and FastCGI modules, Ruby-based HTTP servers, distributed Ruby (also called drb), and XML parsing. Several large case studies are presented, including a peer-to-peer chess server, a message board, and a distributed stock ticker simulation. While two XML parsers are presented (XMLParser and NQXML) the popular pure-Ruby REXML module is not covered here. Also, it would have been nice to have a TupleSpace example included in the section on drb since it is included in that package.

There are two appendices that will be very helpful for Perl and Python programmers interested in learning Ruby, "From Perl to Ruby" and "From Python to Ruby". Programmers familiar with these languages should find these sections quite helpful as quick introductions. It might be nice to have an appendix that covers "From Java to Ruby", but I've already asked for enough.


I found a few errors in the book, and others have reported more to the author. I'm not sure that there are more than is usual for a first edition book, and this certainly isn't the only book I've gotten lately that had more than a few errors in it. (It seems to me that publishers are getting a bit more hasty these days in getting titles out the door without proper reviews, but I digress...) Be sure to check the Web sites listed in the book for errata.


I highly recommend this book for programmers who want to advance their Ruby programming skills. In general, you'll want it as a companion volume to one of the other introductory/reference Ruby books. Those new to any programming should probably start with Mark Slagell's Teach Yourself Ruby in 21 Days. (I normally don't recommend those books that purport to teach you something in X days or hours, but from what I've seen of this one, it's very good) and then get The Ruby Way as their second Ruby book. For Perl programmers, I would say that The Ruby Way is sort of like a combination of the Perl Cookbook and Mastering Algorithms in Perl. Experienced Python and Perl programmers interested in learning Ruby would probably want to purchase The Ruby Way in conjunction with one of the more reference-oriented books mentioned earlier.

Recent comments

11 May 2002 07:09 Avatar chitt

Props and a warning to the SO's out there....
To both Hal Fulton for the book, and Phil Tomson. Ruby makes programming enjoyable again. At my last site, everything was horribly kludged together with Perl. I know good Perl from bad Perl, this was bad Perl (me thinks it was an org problem). Regardless, no matter how burned out the programmer, no one seems to walk away from the language or a book written about Ruby, with anything less than fevored anxiousness and excitement. I must apologize to the significant others of the developers who have read this book, expect many late and excited weekends and nights programming. I'm getting away with this because she's gone to bed and I got up again to work. No point sleeping through an idea... ::grin:: Enjoy. Nice work Hal. -sc


Project Spotlight

Kigo Video Converter Ultimate for Mac

A tool for converting and editing videos.


Project Spotlight


An efficient tagger for MP3, Ogg/Vorbis, and FLAC files.