Tuesday, May 08, 2007

Book Review - Ruby Cookbook by Lucas Carlson and Leonard Richardson

by T. Michael Testi (Blogcritics.org , PhotographyToday, ATAEE)

In the Ruby Cookbook preface, the authors begin by saying "Life is Short." Following with, and I paraphrase, "This book is meant to save you time… but a span of time is also a piece of your life. Our lives are better spent creating new things than… trying to solve problems that have already been solved." The authors hope that by writing this book, they can save you much more of your time than they spent creating the book. As has been my experience with the Cookbook series, their hope is well founded.

Ruby Cookbook is geared toward those who have some experience with Ruby or those who have a strong general background in other programming languages and are wanting to learn Ruby. If you are familiar with a number of programming languages, studying through the first ten chapters should get you up to speed quite nicely.

Ruby is an object-oriented scripting language that originated from Japan. It takes some of the best features from some of the best languages and combines them to make a simple and easy to use yet powerful system for processing tasks. It is freely available as open source software and is available on many platforms including Windows, Mac OS X and Linux.

The Ruby Cookbook contains 23 chapters broken down into loosely six functional areas; Data Structures, Idiom and Philosophy, Storing Data, Applications, Programming Techniques, and Miscellaneous Techniques. You won't find these titles explicitly listed in the book, but for organization (and so I don't have to step through each chapter) I will present, my discussion using them. Each recipe begins with a problem statement. It then follows up with the solution so if you want, you can be done and get on with your life. There then is a discussion if you want to learn more about the solution. It ends with a "See Also" which will give you addition information if the discussion is not enough.

In data Structures (chapters 1 thru 6), the authors cover the built in data structures used by the Ruby language. They cover strings, numbers, dates and time, arrays, hashes, files and directories. These deal with strict algorithmic problems. Some are as simple as 1.10's "Changing the Case of a String", some are more complex such as 4.15's "Partitioning or Classifying a Set" in which you want to partition an array based on some attribute of its elements.

Idiom and Philosophy (chapters 7 thru 10) covers items that you may encounter when you cannot get the Ruby language to do what you want. You will learn things like iteration, blocks and callbacks. You will explore objects and classes, working with superclasses and abstract methods, modules and namespaces as well as reflection and metaprogramming.

In Storing Data (chapters 11 thru 13) you will focus on how to work with three popular forms of data storage; XML, HTML, graphics and database. You will extract data from a tree structure, convert from one encoding to another as well as convert an HTML Document to a text document. You will learn how to thumbnail images, present graphing data as well as generate PDF files. You will work with YAML, MySQL, and Berkley DB as well as learning how to prevent SQL Injection attacks.

Applications (chapters 14 thru 16) will explain how to work with internet services, web development and web services. Here you will explore sending/receiving mail, working with FTP and CGI. They explain working with Ruby on Rails development as well as interacting with sites such as Amazon and Flickr. They will show you how to creat a jukebox, a whiteboard and how to charge a credit card.

Programming Techniques (chapters 17 thru 19) tend to auxiliary tasks of programming such as testing, debugging, packaging and automating tasks. You will be shown how to create and run unit tests, how to use external resources and how to profile your application. You will learn how to package and distribute your Ruby application as well as automate tasks with Rake. Miscellaneous Techniques (chapters 20 thru 23) complete the package with items such as multitasking/multithreading, user interface, extending Ruby and system administration.

Will you have need for all 300 plus recipes in this cookbook? Probably not…today, but perhaps soon! With over 800 pages, there is something for everyone.

No comments: