Metaprogramming Ruby 2 (PragProg)

Dig under the surface and explore Ruby’s most advanced feature: a collection of techniques and tricks known as metaprogramming.

Paolo Perrotta @nusco

edited by Lynn Beighley

Dig under the surface and explore Ruby’s most advanced feature: a collection of techniques and tricks known as metaprogramming. In this book, you’ll learn metaprogramming as an essential component of Ruby and discover the deep, non-obvious details of the language. Once you understand the tenets of Ruby, including the object model, scopes, and singleton classes, you’re on your way to applying metaprogramming both in your daily work assignments and in your fun, after-hours projects.

Metaprogramming Ruby, Second Edition makes mastering the language enjoyable. The book is packed with:

  • Pragmatic examples of metaprogramming in action, many of which come straight from real-life gems such as Rails.
  • Programming challenges that let you experiment and play with some of the most out-there metaprogramming concepts.
  • Metaprogramming “spells”—33 practical recipes and idioms that you can study and apply right now, to write code that is sure to impress.

This completely revised new edition covers the new features in Ruby 2.0 and 2.1, and contains code from the latest Ruby libraries, including Rails 4. Most examples are new, “from the wild,” with more recent libraries. And the book reflects current ideas of when and how much metaprogramming you should use.

Whether you’re a Ruby apprentice on the path to mastering the language or a Ruby wiz in search of new tips, this book is for you.


“The previous edition of Metaprogramming Ruby changed my life and my code, and
helped me get my first programming job. You would think there would be no way
to improve on a book that good, but Paolo Perrotta has done it. Learn to unlock
the hidden potential of this beautiful language, and fall in love with Ruby again.”

–Richard Schneeman
Programmer, Heroku


  • Full details: Search
  • View this book’s portal and details on how to post errata and suggestions here.

Don’t forget you can get 35% off with your Devtalk discount! Just use the coupon code “devtalk.com" at checkout :+1:

4 Likes

I’ve seen that a 3.1 version came out recently. I got the very first one in paperback.
I suppose there’s a huge gap between these two books, isn’t it?

4 Likes

Hey, Maartz. No, definitely not a huge gap. Indeed, it’s just a couple of minor fixes: I just wanted to address the one or two remaining errata. That resulted in a few changed words in the “Methods” chapter, and tiny code fixes to one example that didn’t run on recent versions of Ruby.

4 Likes

Thank you so much for your answer. It will be a bit more challenging which is nice.
Happy holidays and Merry Christmas!

4 Likes

Oh, sorry, Maartz–now I realize that you’re asking about the gap between the very first printing and the latest one. To be clear, do you have the first printing of “Metaprogramming Ruby 2”, or “Metaprogramming Ruby”, the first edition of the book?

I’m assuming that you’re asking about the first case: the changes between the first and last printing of “Metaprogramming Ruby 2”. There are indeed plenty of changes, but they’re small. They’re mostly errata fixes and similar small tweaks. Nothing that justifies re-reading or re-buying the book for sure.

However, if you have “Metaprogramming Ruby” (the first edition), then the changes are pretty substantial–especially in the Rails chapters, that I basically rewrote from scratch.

3 Likes

Merry Christmas to you as well!

4 Likes

Merry Christmas @nusco!

4 Likes

I notice now that I’d missed your message somehow. A very belated Happy New Year! :smiley:

3 Likes

Happy New Year, and thank you! :slight_smile:

2 Likes