Start reading Metaprogramming Ruby: Program Like the Ruby Pros on the free Kindle Reading App or on your Kindle in under a minute. Don't have a Kindle? Get your Kindle here.
Programming Books C Java PHP Python Learn more Browse Programming Books

Deliver to your Kindle or other device

Enter a promotion code
or gift card

Try it free

Sample the beginning of this book for free

Deliver to your Kindle or other device

Anybody can read Kindle books—even without a Kindle device—with the FREE Kindle app for smartphones, tablets and computers.
Sorry, this item is not available in
Image not available for
Image not available

To view this video download Flash Player


Metaprogramming Ruby: Program Like the Ruby Pros [Kindle Edition]

Paolo Perrotta
4.6 out of 5 stars  See all reviews (36 customer reviews)

Digital List Price: $28.00 What's this?
Print List Price: $32.95
Kindle Price: $15.40
You Save: $17.55 (53%)


Amazon Price New from Used from
Kindle Edition $15.40  
Paperback $21.60  
Shop the new
New! Introducing the, a hub for Software Developers and Architects, Networking Administrators, TPMs, and other technology professionals to find highly-rated and highly-relevant career resources. Shop books on programming and big data, or read this week's blog posts by authors and thought-leaders in the tech industry. > Shop now

Book Description

Everyone in the Ruby world seems to be talking about metaprogramming--how you can use it to remove duplication in your code and write elegant, beautiful programs. Now you can get in on the action as well.

This book describes metaprogramming as an essential component of Ruby. Once you understand the principles of Ruby, including the object model, scopes, and eigenclasses, you're on your way to applying metaprogramming both in your daily work and in your fun, after-hours projects.

Learning metaprogramming doesn't have to be difficult or boring. By taking you on a Monday-through-Friday workweek adventure with a pair of programmers, Paolo Perrotta helps make mastering the art of metaprogramming both straightforward and entertaining.

The book is packed with:

  • Pragmatic examples of metaprogramming in action, many of which come straight from popular libraries or frameworks, such as Rails.
  • Programming challenges that let you experiment and play with some of the most fun, "out-there" metaprogramming concepts.
  • Metaprogramming spells--34 practical recipes and idioms that you can study and apply right now, to write code that is sure to impress.

    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.

  • Editorial Reviews


    "If you program in Ruby, buy this book. Twice. Ruby isn’t magic anymore, just great."

    —Joe Alba

    "In Ruby, the practitioners of metaprogramming have found a language where they are only constrained by their imagination. To reach mastery is hard, and even harder is to apply it tastefully. This book gives a grounding in the fundamentals of metaprogramming Ruby in such a way that anyone can pick it up and then immediately start using it. Paolo brings out the core of how simple metaprogramming can be in this book, and that is no easy task."

    —Ola Bini, ThoughtWorks

    About the Author

    Paolo Perrotta has more than ten years of experience as a developer and writer. He worked for domains ranging from embedded to enterprise software, computer games, and web applications. These days, Paolo coaches agile teams for Yoox, a large Internet fashion shop, and teaches Java to developers throughout Europe. He lives in Bologna, Italy, with his girlfriend and a cat. He loves Ruby.

    Product Details

    • File Size: 862 KB
    • Print Length: 296 pages
    • Publisher: Pragmatic Bookshelf; 1 edition (November 6, 2012)
    • Sold by: Amazon Digital Services, Inc.
    • Language: English
    • ASIN: B00A376YAK
    • Text-to-Speech: Enabled
    • X-Ray:
    • Lending: Not Enabled
    • Amazon Best Sellers Rank: #58,512 Paid in Kindle Store (See Top 100 Paid in Kindle Store)
    •  Would you like to give feedback on images?

    Customer Reviews

    Most Helpful Customer Reviews
    53 of 54 people found the following review helpful
    5.0 out of 5 stars Should really be titled "Thinking in Ruby" April 8, 2010
    Format:Paperback|Verified Purchase
    I've read quite a few Ruby books and this is one of the best. The author very effectively does a number of things in this book:

    i) Highlights the conceptual differences between Ruby and other currently popular languages

    ii) Shows how those conceptual differences are expressed in programming constructs by walking the reader through a number of small but realistic example problems

    iii) Reviews internal details of a number of pieces of real-world software (most notably Rails) to show how the authors of these packages use the techniques he describes to solve their problems

    iv) Provides a number of helpful and applicable guidelines on how to 'think in Ruby'

    v) Generates a GoF style catalog of implementation patterns

    vi) Skewers the notion that 'metaprogramming' is any different than regular programming

    After finishing this book I have a real appreciation of the techniques the author describes, and how they can be used to write flexible, powerful, and maintainable software. Before reading this book I was aware of a number of these techniques, but I didn't necessarily understand how they could be effectively used to solve real problems. Now I do. The book truly covers how to think in Ruby - how to naturally solve problems in Ruby, as opposed to adapting techniques commonly used in languages from the C/C++/Java lineage.

    The one major criticism I had of Metaprogramming Ruby was the 'fanboy' tone that permeates a lot of the text. Frequently the author seems more interested in getting you to agree with him that Ruby is great than in conveying the concepts being discussed. There are a lot of gratuitous slams of other languages (especially Java) that were frankly unnecessary and distracted from the book. Had the tone of those comparisons been a little more highbrow and a little less schoolyard, this would have been a better book.

    Overall rating: 4.5 stars
    Comment | 
    Was this review helpful to you?
    22 of 23 people found the following review helpful
    3.0 out of 5 stars I have a love-hate relationship with this book. December 18, 2011
    Metaprogramming Ruby puts non-obvious and non-trivial content together into a coherent whole.

    The technical content of this book is very, very good. The book explains much of the basic structure of ruby (object model, class definitions, blocks, method lookup, etc) in such a way that common idioms that I have previously used without understanding their underlying mechanisms now make complete sense, and my understanding and command of some of the more powerful features of ruby have greatly improved.

    Real-world code examples drawn mostly from ruby gems are included, and these are excellent illustrations of ideas presented.

    As with many technical books, many of the non-real-world code examples are extremely simple and contrived. For the most part, this is acceptable, but there are instances where the tests/sample output provided for exercises were incomplete -- in the sense that you can come up with a flawed and incomplete piece of code which will still make the test pass.

    The thing about this book that drove me up the wall is the insipid story line: You have started a new job, and you have an incredibly chirpy and annoying coworker with whom you must pair program, and who lectures you about the ruby object model, etc. The dialogues are awful; Bill The Asinine Coworker "exclaims" and "shouts" much like characters in bad romance novels supposedly do. The text is littered with irrelevant and distracting details about sipping coffee and grabbing keyboards and ignoring whiteboards in favor of napkins.

    This is possibly the best exposition of the ruby object model available, however, so if you are frustrated by the piecemeal information available on the web and you don't have a chirpy co-worker by the name of Bill to mentor you, I would highly recommend reading this book.
    Comment | 
    Was this review helpful to you?
    28 of 31 people found the following review helpful
    5.0 out of 5 stars Short and sweet March 3, 2010
    I have a BS and MS in Computer Science, and worked with Ruby professionally for two years. I've read every major Ruby book on the market. This book brought me to the next level. If you dig Ruby or Rails and are a programmer looking for the next step, this is it.
    Comment | 
    Was this review helpful to you?
    14 of 14 people found the following review helpful
    5.0 out of 5 stars Essential to Appreciate Ruby's Power April 8, 2010
    A Kid's Review
    I have been programming in Ruby for almost two years, and I have done some Ruby on Rails. With this book I finally begin to understand what Ruby was doing for me all along -- especially when it's running on Rails. Ruby was easy to use like I've used many other languages, but now I understand how unique and powerful Ruby really is. And I'm sure that I will begin to take advantage of that extra power.

    Also: the book is well written and organized. I especially like that whenever a particular topic is mentioned a page reference also appears. This makes it easy to do a quick review of the topic before going further, like "Hook Methods (181)."

    This book will not sit idly on my shelf. I'll be going back to it again and again for review and further mastery of the topics.
    Comment | 
    Was this review helpful to you?
    16 of 19 people found the following review helpful
    This book offers an amazing look into the beauty and power of Ruby. It has made me a better Rubyist. It is accessible and entertaining. Not only is the use of a second-person narrative throughout astonishingly well executed, but the character development is pristine as well, Bill's in particular. In the course of one week we see Bill evolve from strange, overbearing know-it-all coworker to mentor, friend, and even intrigued learner. But that's when things get interesting and take quite a turn in the story. I don't want to give anything major away but Bill sleeps with your wife at the end.
    Comment | 
    Was this review helpful to you?
    Most Recent Customer Reviews
    5.0 out of 5 stars awesome book
    one of the best programming books I've ever read. i highly recommend this to anyone looking to learn more ruby.
    Published 3 months ago by Charles Cogdell
    5.0 out of 5 stars Everything in Ruby makes so much thanks to this book.
    I purchased my books on my quest to understanding ruby, including the very highly regarded PickAxe book, and while some were very helpful I don't think any of them explain how to... Read more
    Published 5 months ago by Adam J Miller
    5.0 out of 5 stars I learned more about ruby from this book than any other
    I didn't expect to enjoy this book as much as I did. I am an experienced software developer who has only recently started working on ruby and rails projects. Read more
    Published 6 months ago by mattx
    5.0 out of 5 stars Best Book I've Read on Ruby
    This book gets to the heart of what makes Ruby such an amazing language. It is also a great example of why reading an in-depth discussion on a topic in (e)book form can be far... Read more
    Published 9 months ago by Todd Sampson
    5.0 out of 5 stars Guts of Ruby Revealed
    This book is remarkable. It goes deep into Ruby internals. The way it explains the Ruby Object Model is truly revealing. Read more
    Published 9 months ago by Naga Vijayapuram
    5.0 out of 5 stars One of the best Ruby books I've ever read
    The book contains great practical examples of how to use metaprogramming, taking you through basic designs and improving them incrementally with concepts from the text. Read more
    Published 10 months ago by Diogenes DogSnack
    4.0 out of 5 stars How the Deep Magic works
    There are lots of nits to pick with this book, and other reviewers have done a good job with them. The quasi-Socratic Dialogues with Bill are weird, the fanboy relationship with... Read more
    Published 13 months ago by M. M. Davis
    5.0 out of 5 stars Excellent
    A great book for anyone who wants to go further and realize the full potential that the Ruby language can give.
    Published 13 months ago by Alessandro Vasconcelos Ferreira de Lima
    3.0 out of 5 stars Great content, bad editing
    This review is specifically for the Kindle version of the book. I'm be willing to be that the printed edition doesn't have the same errors. There are two show stopper problems. Read more
    Published 19 months ago by Michael Nugent
    1.0 out of 5 stars I wish I had read more of the reviews before purchasing
    TLDR: If you prefer reading "...for Dummies" style books then this is probably the book for you. Otherwise stay away. Read more
    Published 24 months ago by Brandon Fosdick
    Search Customer Reviews
    Search these reviews only

    More About the Author

    Paolo Perrotta speaks and writes about software development. He worked as a developer in domains that range from embedded to enterprise software, computer games, and web applications. These days, he mentors and coaches developers throughout Europe. He has a basecamp in Bologna, Italy. He loves Ruby.


    There are no discussions about this product yet.
    Be the first to discuss this product with the community.
    Start a new discussion
    First post:
    Prompts for sign-in

    Look for Similar Items by Category