Programming Ruby: A Book Review

by Ralph Krause

"Use Ruby and you'll write better code,
be more productive, and enjoy programming more", touts the
introduction to this book. Such claims are commonplace for
virtually every programming language out there, but are these
claims true for Ruby?Programming Ruby, written by David
Thomas and Andrew Hunt, is part tutorial and part reference manual.
Ruby is an object-oriented, interpreted language, written by
Yukihiro Matsumoto, that has a large following in Japan (its usage
is currently rumored to surpass that of Python) and is gaining
popularity elsewhere. In addition to ample built-in functionality,
Ruby also has a large selection of libraries and toolkits under
development.The book is divided into four parts, with a tutorial and
language introduction contained in the first two parts, making up
slightly less than half of the book. Part I is a tutorial that
introduces concepts unique to Ruby along with basic syntax. Topics
covered in this part include Ruby classes, standard variable types,
loops, error handling, basic I/O and multithreading. Ruby's
debugger and profiler are also introduced here.Part II discusses how Ruby interacts with its world via
command-line arguments and environment variables. It also
illustrates how Ruby works in other environments, such as the X
Window System using Ruby/Tk, the Web as CGI scripts executed by
mod_ruby on the Apache web server and under Microsoft Windows. The
section finishes by explaining how to extend the Ruby language by
writing C programs and provides sample code for doing so.The third part of the book starts with a concise recap of the
material presented in earlier tutorials, then moves on to advanced
topics. These advanced topics include how Ruby programs can guard
against system modification by external data (important when using
Ruby for CGI scripting), reflection (the ability of a running
program to examine aspects of itself) and distributed
programming.Part IV provides a reference for Ruby's built-in classes and
modules. This section also covers selected standard library modules
such as Ruby's object-oriented design libraries, network and web
libraries. An overview of each module is presented, followed by an
alphabetical listing of its properties and methods, complete with a
brief explanation and code snippet illustrating usage.The final part of the book contains appendices on embedded
documentation, the interactive Ruby shell, sources for Ruby support
and a bibliography.New Ruby programmers can read through Parts I and II to get
an understanding of how Ruby works. Those familiar with other
object-oriented languages, or trying to find specific Ruby
functionality, can jump to the reference sections of the
book.The book's writing is generally clear and illustrations help
clarify difficult concepts, but there is room for some improvement.
For example, code in later chapters depends on code from earlier
chapters, but this isn't always pointed out. Also, the code
snippets aren't labeled, just mixed in with the text, which can
make it difficult to find the needed code.A powerful feature of Ruby is code blocks, used when writing
iterators or defining code to be run under transactional control.
The book presents several examples of blocks and iterators, but
they don't seem very illuminating. Some figures or a bit more
explanation in the text would be welcome.All of the example code that I tried worked, except for the
HTTP example on page 111. A look at the book's web site didn't
provide an answer to the problem, but I did find a workaround by
doing a search of comp.lang.ruby in the Google/Deja News
archives.I would also have liked to see more examples of complete Ruby
programs like the last Ruby/Tk example on page 161. This would help
illustrate how to put all the pieces of a Ruby program together and
how modules and classes interact.I think Programming Ruby is a good book,
and I did gain an understanding of what Ruby is and how it works. I
found some code examples, such as the Ruby/Tk programs, useful and
informative. The book does lack depth when explaining concepts such
as code blocks, however, and this could keep it from being the only
Ruby book that you would need.Product
Information and Resources
Ralph Krause lives in
Michigan and has been using Linux for over three years. He is
working at becoming a prolific writer, highly sought after web
designer and a happy programmer.

email: rkrause@netperson.net

Load Disqus comments

Firstwave Cloud