Forgot your password?

The Ruby Way 81

Posted by samzenpus
from the way-she-goes-boys dept.
Tim Hunter writes "Hal Fulton's The Ruby Way, Second Edition doesn't try to be the only book a Ruby programmer needs. It tries to be a book every serious Ruby programmer needs, and it succeeds. The Ruby Way is a book about programming with Ruby, the object-oriented programming language from Japan. Ruby is free software and runs on Linux, Microsoft Windows, Apple OS X, and other operating systems. It is available for download from its web site, or its companion site Read the rest of Tim's review.
The Ruby Way, Second Edition
author Hal Fulton
pages 839
publisher Addison-Wesley
rating 9
reviewer Tim Hunter
ISBN 0-672-32884-4
summary A task-oriented book about the Ruby programming language

I read the first edition of The Ruby Way when it was published in 2002, not long after I starting programming in Ruby. I was a member of the discussion group Fulton organized during the writing of this edition. I am also the author of RMagick, one of the libraries described in this book, and did the technical review of that section.

This is a review of the second edition of The Ruby Way. The first edition described the then-current Ruby syntax and libraries and showed novice Ruby programmers how to perform common programming tasks. In the past four years Ruby has evolved and its community has grown immensely. Consequently, the first edition was starting to look a little long in the tooth and the Ruby community has been eager for the appearance of a new edition. This edition is almost a complete rewrite. Saying that it's 260 pages longer minimizes the actual scope of the changes. There are a dozen new chapters. Some of the new material expands on topics that were present in the older work, like regular expressions and data structures. However, much of the new material covers topics that simply didn't exist 4 years ago, such as Ruby's XML and RSS libraries, RubyGems (Ruby's answer to CPAN), and Rake, the Ruby version of make.

The Ruby Way doesn't try to teach how to program in Ruby. For that, you need Dave Thomas' Programming Ruby: The Pragmatic Programmer's Guide or a similar book. The goal of The Ruby Way is nothing less than describing the universe around the Ruby programming language. In one 800+ page volume, it describes Ruby's design principles, history, syntax, built-in classes, standard libraries, 3rd-party add-on libraries, related development tools, and user community. The examples and Fulton's explanations emphasize Ruby programming best practices, hence the title.

Fulton describes The Ruby Way as an "inverted reference." A typical reference book for a programming language lists the libraries, classes and methods by name, which you can use to discover their purpose. The Ruby Way, on the other hand, groups Ruby's libraries, classes and methods by purpose, from which you can discover their names. Section titles tend to describe tasks, such as "Tokenizing a String" and "Interacting with an IMAP Server". The sections then describe the split method in the String class and the net/imap library, respectively. Several chapters group Ruby libraries by related tasks. For example, Chapter 15 describes Ruby libraries used to process specialized data formats such as XML, RSS, images, and PDF. In this chapter you will learn that XML processing in Ruby is typically done with REXML and that PDF files can be created with PDF::Writer, etc. Organizing topics by purpose or function instead of by name makes it easy to discover what parts of Ruby you need to complete a task.

Unlike many of the 2-inch thick books about programming for sale lately, there is no fat in The Ruby Way. It hits the ground running with an introduction to object oriented programming and a whirlwind tour of Ruby syntax. It covers Ruby's built-in classes in considerable depth. The String class gets an entire chapter, as do regular expressions. Array and Hash rate yet another chapter. Fulton continues with an in-depth survey of Ruby's extensive standard library. Interested in object persistence? Chapter 10 describes Ruby's YAML library. Wondering about unit testing? Go to Chapter 16 to read about the Test::Unit library. One of the most frequently asked questions to the ruby-lang mailing list is "what GUI libraries are there for Ruby?" Chapter 12 supplies sample applications that demonstrate graphical interface libraries such as Ruby/Tk, FXRuby, and QtRuby. Chapter 19 is dedicated to web application development tools ranging from the famous Ruby on Rails to the lesser-known but equally useful Nitro. Chapter 22, "The Ruby Community," tells where other Ruby programmers hang out. Catering to his programmer audience, Fulton peppers each section with code snippets and complete example programs. (The source code for the book can be downloaded from Fulton's web page.)

Although Ruby is thought to be a "Linux-centric" language it also has a large audience in the Microsoft Windows community. Fulton addresses these users' needs with a description of the "One-Click Ruby Installer" for Windows. This description is accompanied by a section about the Ruby libraries available for scripting on Windows. For example, Fulton shows how to open a file dialog box using the Win32OLE library.

Fulton says that he doesn't expect anybody to read his book from front-to-back. Nevertheless The Ruby Way is quite readable and (if not for its considerable weight) would make a good book for browsing while waiting for the bus, or between classes. Some sections contain a surprising amount of general background information, such as the remarkably in-depth description of Unicode in Chapter 4. Not content to simply educate the reader, Fulton continues his practice in the 1st edition of entertaining the reader with thoughtfully chosen quotes, geek humor, and personal observations.

Is there anything not to like about this book? Well, to be perfectly honest I occasionally found myself wondering if sometimes Fulton spread himself too thin. The amount of coverage for individual classes and libraries varies widely. Some of the standard libraries, like REXML, get several pages of description and an accompanying example while others, such as open-uri, get only a cursory introduction and a pointer to the on-line documentation. At 4 pages, the section on Rails is perfunctory and, given the number of very good books already available on the subject, redundant. (Fulton himself says the material is "cursory.") I have to wonder if it isn't there simply because "everybody" expects books about Ruby to say something about Rails. Similarly he devotes a single page to ActiveRecord, which, as a part of Ruby on Rails, is capably documented elsewhere. That page would've been better used to double the number of pages spent on Og, another Ruby ORM which is not so richly documented.

I recommend this book to any programmer who has already learned the basics of Ruby syntax and its built in classes and who wants to learn more about using Ruby to accomplish typical programming tasks. While it will be particularly useful to the novice Ruby programmer, it is a handy reference for Rubyists at any level of experience.

You can purchase The Ruby Way, Second Edition from Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.
This discussion has been archived. No new comments can be posted.

The Ruby Way

Comments Filter:
  • by archen (447353) on Wednesday November 08, 2006 @01:29PM (#16771701)
    Ruby at it's core is a nice language. I started migrating from Perl (after deciding I didn't like Perl6) about 2 years ago. I just recently became serious about it within the last few months. I think at this point Ruby's main weakness is in it's libraries. I came up with some deficiencies in dbi, but mostly got it working.

    Then I started working with cgi.rb . Didn't have any problems until I tried uploading files. What kind of data do you get back? That sort of depends on if your script receives a GET or POST, and if the post is over or under 10k. Also fun trying to detect those objects because it will toss you back something like a Tempfile object even though you haven't "required" it. I was actually really amazed (and pissed) that such garbage could be included as a core library - especially for a language that is supposed to make your life so easy.

    Ruby has a lot of work in the library department, and a HELL of a lot of work in the documentation department.
  • Re:Ruby! (Score:3, Informative)

    by JerkBoB (7130) on Wednesday November 08, 2006 @01:47PM (#16772037)
    Ruby Seems ALOT like Perl, Atlest to me, anyway lets hope this doesnt flop like other projects in the OSS wild

    Umm... Ruby has been around for a decade. It's huge in Japan, where it was created. It has gained prominence here in the West because of Rails, but it's a great general-purpose language.

    As for its similarities with Perl, I describe Ruby as the lovechild of Perl/Smalltalk. I've made some good money hacking in Perl, but after having discovered Ruby two years ago Perl is just painful to look at, much less program in.
  • by Peter Cooper (660482) on Wednesday November 08, 2006 @01:53PM (#16772211) Homepage Journal
    The reviewer is right, it's a good book. It has a few inaccuracies (confusing a TIME server with an NTP server, for example) but generally it contains hundreds of code snippets that allow anyone experienced with OOP or other dynamic languages to pick up Ruby pretty easily. As he says, it's not a 'learn Ruby' book but it could be ideal for those who want to learn without being 'told' what to do.. it's just got hundreds of code examples that are written in the clean, most acceptable Ruby style, and if you can learn from code examples, it's the best book to buy right now.

    Be warned, however, it doesn't go into much detail about things like libraries or Ruby on Rails, so it's not a bible to the whole Ruby ecosystem, but for the Ruby language by itself, it's great.
  • by Zarniwoop_Editor (791568) on Wednesday November 08, 2006 @02:31PM (#16773117) Homepage
    I assume you are accusing me of lying about the site being ruby/rails based?
    It's hosted on their cheapest dedicated server ($59), running freebsd, apache with fast-cgi and ruby / rails.
    Wasn't really interested in getting involved in a flame war.
    Best to be sure of your facts before calling someone a liar.
    You are however entitled to your opinion. Truth is I'm really enjoying playing with ruby/rails.

1 Mole = 007 Secret Agents