Ruby Cookbook

Vedi tutte le pagine e le modifiche recenti o scarica i sorgenti nella pagina


Ruby Cookbook Lucas Carlson & Leonard Richardson O’Reilly

Reviewed by Giovanni Corriga

Ok. Let’s pretend you’re a Java programmer, and you want to know what’s the story about this Ruby language you’ve heard so much about. Or maybe, like me, you’re a Smug Smalltalk Weenie and you want to check how the young cousin from the East is doing. Either way, you got your hands on a manual or on a tutorial, and now you’re reasonably sure you have a good grasp of the language. But you still have to learn the slang, and that is the difficult part.

But don’t worry, here comes the Ruby Cookbook to the rescue. The book is a full, 850-pages behemoth full of Ruby tips and tricks, from string manipulation to database management, from reflection to multitasking.

Presenting their tips in the usual cookbook format , the two authors cover almost all the topics of interest for both the beginner and the expert Ruby programmer.

The book is divided into six parts, with each part divided into chapters.

The first part covers the basic of the Ruby language: strings and numbers, date and time, arrays and hashes, files and directory. The Ruby newbie will find this part the most interesting, but there are a couple of tricks even the expert will find useful (I’ll never underestimated the power of #inject any more).

The second part is devolved to Ruby idioms and philosophy: as the authors write, it will help you write code that looks the way Ruby “should” look. So we have blocks and iterations, classes and objects, reflection and metaprogramming. This is the part I enjoyed the most, even if sometimes the terminology used is a little confused (but that’s probably me).

The next part covers file formats. From XML and XHTML to databases and persistance, through graphics, sounds and archiving. Lots of juicy stuff here, that you never know when it can become useful.

After the file formats, it’s the turn of network protocols: HTTP/HTTPS, POP, IMAP and SMTP, even a simple BitTorrent client. The omnipresent Rails framework can’t be overlooked, and it has its own chapter. This is particularly useful, since it also covers advanced topics like Ajax and script.aculo.us effects.

The fifth part is useful when you’re creating Ruby applications: it covers testing, debugging and profiling, building gems and standalone packages, using Rake to automate the menial tasks.

The last part includes miscellaneous topics: multitasking, GUI programming, writing C extensions and using Ruby for system administration. Since that’s my current use for Ruby, I read that part very carefully, and I’ve immediately applied some of the tricks discussed in the chapter.

All in all, the Ruby Cookbook is like a dictionary that you should keep by your side when you’re programming in Ruby. The only small con is the high number of typos, especially in the first part: nothing which stops you from understanding what the authors are saying, but finding a typo in almost every page of a chapter gets tiresome after a while.

Anyway, you can’t go wrong by buying this book.

Pros: too many useful tips to even count’em.

Cons: one more pass at proofreading would have been useful.

Updated on August 11, 2006 12:59 by Giovanni Corriga (87.6.86.128)