Because of the recent and sudden interest in Ruby on Rails, there is quite a demand for books that can help people learn to program efficiently in Ruby. Though the language itself encourages fast learning and a high degree of programmer productivity, there are still a number of commonly solved problems and frequently written algorithms that you shouldn’t need to reinvent to start programming in Ruby. And — as usual — that’s where the O’Reilly Cookbook series comes in.
Writing analysis
If you’re familiar with the Cookbook series, you’ll know what to expect with Ruby Cookbook — it’s a fine example of the series. If this is your first Cookbook, you’ll probably find it a little strange. Instead of a conversational or instructional text that shows you Ruby through multi-page code examples, programming exercises, or explanations of syntax, Ruby Cookbook is broken up into short chapters that show you how to solve common Ruby-specific programming problems. If there are multiple valid solutions to a particular problem, the book will show you all of them. You quickly read about the problem, then the most simple and logical solution to it, and then a more complex solution that takes more details into account. After that, you’re given a short explanation of how the solutions should be implemented.
Chapters are broken up into topic-specific sections. The book starts out with a series of chapters on strings, then moves on to problems that involve numbers, date and time, arrays, hashes, files and directories, code blocks and iteration, objects and classes, modules and namespaces, reflection and metaprogramming, XML and HTML, graphics, databases and persistence, Internet services, Web development with Ruby on Rails, Web services and distributed programming, testing, debugging, optimizing, documenting, packaging and distributing software, automating tasks with Rake, multitasking and multithreading, user interfaces, extending Ruby with other languages, and system administration.
Putting the book to the test
I found the solutions in Ruby Cookbook to be both relevant to modern programming and easy to implement and adapt to real-world situations. Additionally — and perhaps this is a more important use for this book — it shows you the both the limits and benefits of Ruby in a way that no other Ruby book I’ve seen can do. Since Ruby is so dramatically different from the majority of today’s relevant high-level languages — that is, it’s so simplified that it almost doesn’t make sense to a C or C++ programmer — experienced programmers will likely want to know right off the bat what Ruby is made of and what it’s best used for.
You can put Ruby Cookbook to work instantly by identifying the problems you’re facing and looking for their equivalents in the book. Even if your problem is not covered directly, chances are there are chapters in the book that are close enough that you can at least get a head start on an intelligently constructed solution. What makes the Cookbook series stand out from other programming language texts is that it is problem-centric rather than code-centric. In other words, you’re shown how to solve specific challenges in programming, like how to convert a string to an array, or how to determine what day of the week it is. From there you can plug it into your program, or use the book’s techniques to develop a solution that fits your specific situation.
Conclusions
The Ruby Cookbook is an indispensable tool for current or prospective Ruby programmers, both as a means of learning the language by showing how it works, and as a desk reference to help out when you don’t know how to deal with a particularly challenging problem. I’m glad to have this book on my shelf.
| Title | Ruby Cookbook |
| Publisher | O’Reilly |
| Author | Lucas Carlson and Leonard Richardson |
| ISBN | 0596523696 |
| Pages | Paperback, 873 pages |
| Rating | 10 out of 10 |
| Tag line | Recipes for object-oriented scripting. |
| Price (retail) | U.S. $33. Buy it from Amazon.com |
Discuss this article or get technical support on our forum.
Copyright 2006 Jem Matzan.
|
|
This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 2.5 License.
|
|
Copyright 2008. All content items belong to their respective authors.


