Overview

Paolo Perrotta, as the back cover of the book describes him, has programmed “for more than a decade and published hundreds of technical articles along the way.” Before “falling in love with Ruby,” he wrote in Java, C++ and C#. Once you begin reading this book, you’ll understand why he is successful as a Ruby trainer in Europe and why he is an Agile coach at Yoox

The Forward of the book was written by “matz” (an accomplished Ruby programmer as I understand it,) but it really doesn’t lend any weight to the value of the book because it’s just a summary of what Metaprogramming is and not an endorsement of the author or even the book itself.

Metaprogramming Ruby is divided into two parts (three if you include the Appendices): Metaprogramming Ruby and Metaprogramming in Rails. Although the section names are similarly titled they are quite different in what they seek to accomplish.

In Part I, the author places the reader in the role of a new employee paired up with a more senior programmer, Bill. Bill has “some months of Ruby under his belt,” and acts as a guide and mentor through the weird and wild world of metaprogramming.

In Part II, the book slips back into the more customary technical manual role. Building upon what was learned in the first section, the author delves into Rails itself and brings to light the hidden mysteries of ActiveRecord and ActionController.

Table of Contents

Introduction

Part I: Metaprogramming Ruby

  1. Monday: The Object Model
  2. Tuesday: Methods
  3. Wednesday: Blocks
  4. Thursday: Class Definitions
  5. Friday: Code That Writes Code
  6. Epilogue

Part II: Metaprogramming in Rails

  1. The Design of ActiveRecord
  2. Inside AciveRecord
  3. Metaprogramming Safely

Part III: Appendixes

A. Common Idioms
B. Domain-Specific Languages
C. Spell Book

What’s Good

At first I was a little put off by the storyline of Part I. Having read countless computer manuals and never having run across an instance where the reader was brought into the story, I was initially apprehensive. That apprehension quickly dissolved as I found myself more engaged with the book because of the storyline. I really don’t think there are many writers (of computer manual) who could pull off this sort of style and get away with it. Paolo Perrotta does so with ease. Not surprisingly, it makes reading this part of the book much more enjoyable and memorable.

What is good about this book by far is not the style the author uses, but what the book actually accomplishes: It makes the advanced aspects of Ruby seem not so intimidating. For many of us, metaprogramming really does seem like magic. We look at the code, scratch our heads, and just assume we’re too dense to get it. Metaprogramming Ruby shows us that not only is it not magic, but that any programmer can do it and even understand what others have done.

What’s Not So Good

I hate to say it, but what’s good about this book is also what is bad about it. When you have a technical book which is so approachable and easily read, it’s generally not going to perform well as a reference book. Personally I really don’t see myself using this book much. I plan on reading Part I again - maybe once again after that - but I don’t imagine I’ll crack it open after that. It will, however, make books like The Ruby Programming Language more accessible.

Conclusion

If you scratch your head in wonder at the magic you see going on in Rails and other Ruby projects, or if you think you’re just not accomplished enough as a programmer to access the more advanced areas of Ruby, check out this book.

For the Ruby programmer, it really is worth the time and effort to understand the more advanced areas of the language and this book will be a great guide to help you unlock the magic of Ruby.