February 10, 2010
Metaprogramming Ruby--New from Pragmatic Bookshelf: Program Like the Ruby Pros
Raleigh, NC—Ruby is magical: it can manipulate itself at runtime. Few languages can do this. Ruby supports code that writes code (metaprogramming) in a more dynamic way than you can do using code generators or compilers. With Ruby, runtime isn't set in concrete like an aging building. Instead, it's more like a busy, thriving marketplace. Bits of code can walk up to other bits and ask them questions about themselves, and work out what to do next. These techniques make it far easier to extend and adapt existing programs as they're running.
The problem is that metaprogramming techniques have been out of reach for common Rubyists--let alone for newbie Rubyites. But according to author and developer Paolo Perrotta, the flexibility and elegance of metaprogramming "isn't an obscure art reserved for Ruby gurus." In his new book, Metaprogramming Ruby: Program Like the Ruby Pros (Pragmatic Bookshelf, $32.95), Perrotta clearly describes 34 "spells" or language patterns that make metaprogramming understandable to Rubyists at all levels.
The book, Metaprogramming Ruby, uses stories and case studies to teach the techniques. Part 1, Metaprogramming Ruby, follows a new programmer as he learns the five core concepts: the object model, methods, blocks, class definitions, and code that writes code. Part 2, Metaprogramming in Rails, is presented as a case study. Readers closely examine source code in Rails--the flagship Ruby framework--and see how the masters actually use metaprogramming to develop real-world software.
Fun but provocative quizzes encourage readers to dig in--or to run off and think about the concepts. Three appendices expand the book, gathering useful idioms, resources on domain-specific languages, and a summary of the book's magic spells for metaprogramming.
To Perrotta, there's no reason for Ruby programmers to be intimidated by metaprogramming or to consider it a "bolt-on power feature." He writes, "If you want to take the path to advanced Ruby coding, you'll find metaprogramming at every step. Even if you're happy with the amount of Ruby you already know and use, you're still likely to stumble on metaprogramming in your coding travels: in the source of popular frameworks, in your favorite library, and even in small examples from random blogs. Until you master metaprogramming, you won't be able to tap into the full power of the Ruby language."
With Metaprogramming Ruby, new and experienced Rubyists can follow a practitioner's journey to learn metaprogramming and then dive into examples of live code written by Ruby masters. Like the best teachers, Perrotta strips away what's mysterious or intimidating about his subject--and delivers the magic.
"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
For a review copy or more information please email firstname.lastname@example.org. Please include your delivery address and contact information.
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.
For more information about the book, including code, errata, discussions, full table of contents, excerpts from the book and more, see the catalog page for Metaprogramming Ruby: Program Like the Ruby Pros.
Publisher: Pragmatic Bookshelf
Book Price: $32.95 USD, £23.99 GBP
About Pragmatic Bookshelf
Pragmatic Bookshelf is an imprint of the Pragmatic Programmers, LLC. Our titles are distributed to bookstores internationally by O'Reilly Media.
The Pragmatic Bookshelf features books written by developers for developers. The titles continue the well-known Pragmatic Programmer style, and continue to garner awards and rave reviews. As development gets more and more difficult, the Pragmatic Programmers will be there with more titles and products to help programmers stay on top of their game.
O'Reilly Media spreads the knowledge of innovators through its books, online services, magazines, and conferences. Since 1978, O'Reilly Media has been a chronicler and catalyst of cutting-edge development, homing in on the technology trends that really matter and spurring their adoption by amplifying "faint signals" from the alpha geeks who are creating the future. An active participant in the technology community, the company has a long history of advocacy, meme-making, and evangelism.
Return to: O'Reilly Press Room
Recent Press Releases
Press Release Archive »
Media Relations - North America
Media Relations - Germany
Media Relations - Japan
Media Relations - United Kingdom
Media Relations - Conferences