Home - Network Programming

Product Details

Binding:

Paperback

EAN:

9781934356470

Label:

Pragmatic Bookshelf

Feature:

ISBN13: 9781934356470

Condition: New

Notes: BRAND NEW FROM PUBLISHER! BUY WITH CONFIDENCE, Over one million books sold! 98% Positive feedback. Compare our books, prices and service to the competition. 100% Satisfaction Guaranteed

Publisher:

Pragmatic Bookshelf

Studio:

Pragmatic Bookshelf

Editorial Reviews

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.

Customer Reviews

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
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.
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.
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.
This is the first technical book I have ever read written like this. I'm a author myself and this book has changed the way I think about writing articles, white papers and books. If you are just starting out in programming ruby or are a season veteran in ruby you need to pick up this book. The way it is written it is well put together and it makes you keep wanting to read more. This is not your normal technical boring go through the motions book. It's like a technical novel that is the best way to put it, I never met the author (hope to do so in the future to thank him) but sometimes when reading books all you need is one idea or 1 chapter or even one word to change the way you look at things. Paolo creates a setting like you just was hired at a new company and on Day one they want to implement a project in ruby, so a virtual character "Bill" your mentor your programming lead helps you along the way. I loved the postit notes and napkins he uses in a conference room to give you the skills you need to work on the project and it makes it realistic. I've read hundreds of books but this is the first tech book that has really made an impact in my career in terms of the way I think about writing, if more books were written like this tech books would be best sellers!!! Paolo Perrotta Thanks for writing Metaprogramming Ruby!
I've never written reviews on Amazon, but I felt I had to for this book. It's very elegantly written, as he takes the same format as the way one learns software craftsmanship in real life: solving real world problems under the guidance of a mentor.

In this scenario, you take the role of a new employee at a company guided by the Ruby expert named Bill, on a one week crash course journey though the object model, method creation, blocks, class internals, and finally putting this all together to write a piece of code that seem oddly familiar to the base files you see in some of the famous gems.

The book then goes on and ties this ruby knowledge to a Rails specific lens, examining the internals of ActiveRecord, taking a quick tour of Merb, and then having a glossary of metprogramming "spells" useful for everyday work.
This is a gem (no pun intended) among Ruby books and, in fact, among programming books in general. What sets this book apart from other programming books is its focus on having the reader deeply understand the ruby programming model whether you are a novice or an expert. This is an achievement few other programming books can claim. While meta-programming in ruby is certainly a pleasure when compared to other oo languages, it is still a rather arcane subject, and for this author to be able to explain it on a deep level to beginners is simply awe inspiring! There is also plenty of material for the advanced rubyist including a chapter devoted to what I like to call "dynamic adaptive programming" but will be known more familiarly as "code that writes code". But even the expert will want to read the whole text for its clear, almost zen-like treatment of meta-programming. If I were to be a complete novice to ruby, instead of reading the basic texts like Programming Ruby 1.9: The Pragmatic Programmers' Guide (Facets of Ruby) and The Ruby Programming Language (although the oreilly book should at some point be read thoroughly at some point), I would simply read this book and the following book in tandem: Design Patterns in Ruby.
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.
Anybody who has wondered about the magical code in Ruby source code and has had only a patchwork understanding of Ruby metaprogramming from various sources will find it all explained here.

The major complaint about the book from these reviews is the narrative style of the exposition. I read the complaints before picking up the book so I was prepared--and found them unwarranted.

The purpose of the story and characters is to provoke thinking and understanding. The method succeeds.
Coming from Java, this book was very important for me in filling in a lot of the gaps in understanding Ruby. "Metaprogramming" may sound like a topic best saved for expert practitioners, but I think this is important stuff for everyone - you'll actually understand how all of that magic code you see in various modules and libraries works under the covers.

I would read this before reading a Rails book.
I have used Ruby for production middleware programming since 2005 yet there were nagging gaps in my knowledge of how everything worked together. No longer. Metaprogramming Ruby provides the best explanation of the Ruby object model available anywhere.

The sub-title may be somewhat presumptuous, but it will certainly change the way you approach Ruby programming. This is essential.


This book is well written and quite easy to read. The author takes a novel approach at presenting one of ruby's more difficult topics/features. The topics are introduced as conversations that take place between two developers over the course of a week as they solve real world problems.

After reading this book, I can personally say that some of Rails more magical features don't seem so magical anymore. Now they just make sense!

H
Before anything else, I have to say I really didn't like the style the author chose for the first part of the book. In the chapters named "Monday" to "Friday", you go through your first week in a new job, doing pair programming with your colleague "Bill". While this is fun for about half a page, sentences like "Bill walks over to the whiteboard and starts drawing a blablabla" get old fast. Very fast. I'm not exactly sure why the author decided on this style, since in my opinion it doesn't add anything to the text. As Greg Brown showed in "Ruby Best Practices" you can write an engaging text about advanced Ruby concepts without falling back to alibi prose. The second part of the book deals with some Rails internals and is written in a "normal" style, which I much prefer.

With that out of the way, "Metaprogramming Ruby" is a very good book. The concepts and their presentation are solid and the author knows where to draw the line and leave things for further exploration by the reader. I think there's a slight over-use of footnotes and sidebars, which can disturb the reading flow a bit, but it's not very dramatic and unfortunately this is not that uncommon in technical books.

What I like best is the author repeatedly points out that the distinction between "regular" programming and metaprogramming are blurry in Ruby at best, and that the latter in the end isn't some obscure sort of magic, but "just" a powerful set of tools that can be immensely helpful when used responsibly. Even advanced Ruby programmers are likely to pick up a new trick here or there or at least further their understanding of certain concepts.
This was exactly what I was looking for. I have a good handle on object oriented programming but was having trouble around understanding some of the Ruby Meta-programming techniques. This book is a very good introduction for those only newly come to Ruby, with excellent examples throughout.
This review is by Satoshi Asakawa from Japan, who teaches Ruby Metaprogramming at [...]

Why I like this book?
I could have written the following code like in C:

// C code
int main(void)
{
int i;
for (i = 0; i < 10; i++)
printf("I love you. ");
return 0;
}

But, in Ruby, I can write it more straightforward and simpler -

# Ruby code
10.times{print 'I love you. '}

Ever since I saw this Ruby code, I've fallen in love with Ruby.

After that, I've been enjoying reading tutorials and blogs on the Internet which taught me interesting Ruby tips and tricks. However, what I really wanted to get my hands on was Ruby Metaprogramming.

I've read various articles on Ruby Metaprogramming, but unfortunately I could not understand them well. Everyone said Metaprogramming is too advanced a feature and too early for me to learn. Then I luckily met this book. I started reading the introduction and the story about Bob and Bill.... and I found that I was getting crazy about this book. After reading the first part, Bob and Bill's whole week story, I felt that I wanted to write Ruby code freely. And felt I may be able to do that...

Now I've been reading the second part, Metaprogramming in Rails, again. It's different from the first part. Auther shows us the code which is used in a real project and adds some explanations. I didn't understand it very well on my first read, but after reading and trying out the code again and again, I started becoming comfortable with it.

Auther Paolo says the following in an interview with [...]: When you understand metaprogramming, that's the moment when you start "thinking in Ruby".

We'll be able to write Ruby code as well as native language.... Fantastic!! Well, we need to learn more and more about this, but I'm dreaming with this book!
I know a lot of people might be turned off by the idea of "metaprogramming", but this book is a very good, clear and concise description of how Ruby simply *works*, and even if you don't do a lot of funky things with it, it'll help you understand scope, inheritance, etc... Highly recommended.
Reading this book is like being trapped in an all-day team building exercise.

There's a lot of good information, but you'll have to skim through a lot of bad dialog to find it. For reasons I can't understand, the book superglues you to an annoying and badly-written "programming buddy" named Bill, and way too much of what the book has to teach is buried in his dialog. A third of the book could be pruned by nixing Bill, and the book would be more understandable and less painful to read as a result.

Entire chapters are spent on topics that could be dispensed with in a few paragraphs and the beginning of the book lingers on information that an intermediate programmer would already know. But the strange dialog style buries information so it's difficult to skim or skip. This improves towards the end.

The following quote is an example of what you're in for:

"Forget about method_missing() for now -- we'll get to that this afternoon. To introduce Dynamic Methods, allow me to tell you a story from my youth," he says. "When I was a young developer learning C++", Bill muses, "my mentors told me that when you call a method, you're actually sending a message to an object. It took me a while to get used to that concept. Of course, if I'd been using Ruby back then, that notion of sending messages would have come more naturally to me." Bill launches into a mini-presentation.

A few sentences later comes this: "'Wait a minute,' you interject. 'Why on Earth would I use send() instead of the plain old dot notation?'"

Why on Earth, indeed.

It's condescending, wrong-headed, distracting and agonizing. The concept is very badly suited to the subject matter and that's a shame; the author obviously knows the material and the book could have been excellent. But for some reason, someone decided the book would use a tone usually reserved for explaining rules to slow children. I suspect the book's trying to mimic Why's Poignant Guide to Ruby, which is a horrible trend I see creeping into other Ruby books.

Criticism aside, this is the best book I've found on the topic to date. Bring a highlighter with you and try to ignore Bill. This is the best you'll find for the moment.
I've been using Ruby for about 3 years now and thought I had a good understanding of the language and its capabilities. Wow, was I wrong! This book was like a grenade going off in my head that rearranged my perception of Ruby programming reality. There is a ton of good information in this book that can be used for new projects, refactoring, and anything in between.

A great thing about this book is that it presents these cool but seemingly impractical techniques, and then gives you a great real world example of just how common and practical it really is. Another thing I wasn't expecting is the humor. I laughed out loud reading some sections of the book.

I'm not sure that I'd recommend this for the new Rubyist, but if you have a decent foundation, this book will take you to the next level.
So I've gone through the standard due course on the road to ruby mastry. I've read the pickaxe, achieved enlightenment with ruby koans and built a few basic sites in ruby on rails. I was always left scratching my head with the more advanced rails magic. I looked online and found a few resources but nothing that opened my mind so exhaustively as metaprogramming ruby.

Long story short, if you are serious about taking your ruby skills to the next level, you owe it to yourself to get this book.
The technical writing is incredibly good. It's organized, and to the point. I would first learn ruby from another book, spend a few months writing ruby code, and then get this book. I think the topic is pretty narrow, but even if you don't use the techniques very often, it will take your ruby programming to the next level.
every now an then you you come across a book and you know, this one i will read many times over in the future ....

Meta-programming is one of those, its beautiful written, whit-full, smart and still as concise as the topic it speaks about.
it may not be the "Ruby" book, nor the library on Meta-programming techniques. i think its best used as a book about
style and programming technique. as in inspiration to learn new tools, understand how those "spill's" work in Ruby
and most important as an inspiration to write cleaner, more esthetic code
This is one of the best Ruby books I've ever read. (BTW, another one of the best is "Design patterns in Ruby".)

Now I'm reading it the second time. It's enjoyable reading it.

If you're a serious Ruby developer, you HAVE TO own a copy of it.
METAPROGRAMMING RUBY: PROGRAM LIKE THE RUBY PROS provides tips on metaprogramming to programmers at all levels, from beginners to experts, and explains metaprogramming techniques in a basic style. From understanding the basics of Ruby's options and models to applying metaprogramming in daily work and projects, this packs in fine examples of metaprogramming in action and over thirty practical recipes to write better code. Any Ruby collection must have this.
There's a lot of great information in this book that you won't find in any general-purpose text on the Ruby language, but it's written in a really annoying tone that attempts to present said information as a story. That story is very boring, gets old after the first paragraph, and makes it very difficult to find the code you want amidst the sea of useless prose. An abridged version for people who don't need the spoon feeding would be great.
If you want to learn in detail how Metaprogramming Ruby works, by all means: buy this book, it is very useful!

The content of the book is excellent! The techniques described are very useful, and the author uses mostly good examples to illustrate the use of the different recipes. As a side-note, I also recommend the screencast series by PragProg.com about Metaprogramming Ruby. The book has three chapters which cover how Metaprogramming is used in the Rails framework, which is also very useful.

So far, so good, BUT......

The downside of this book is the writing style -- I'm quoting from orangekay's review here on Amazon:
[...] it's written in a really annoying tone that attempts to present said information as a story.
That story is very boring, gets old after the first paragraph, and makes it very difficult to find
the code you want amidst the sea of useless prose.

I can only second that statement! It is extremely annoying to read this book because of the stupid side-story, and it is very hard to find the relevant concepts later. The names of the concepts/recipes discussed in the book are mostly badly chosen, which is both annoying and confusing later.

I'm wondering why this style was chosen.. to add pages? It's so annoying that I feel tempted to take a big fat black marker and x-out all this junk from the silly side-story. If I had this in an editable electronic form, I would re-format the content!

I wish the author would take these comments to heart, and in the next version of the book, would follow a standard format, e.g. a "Cook-Book" approach, to discuss the techniques described in this book -- without a side-story!

If you want to learn in detail how Metaprogramming Ruby works, by all means: buy this book, it is very useful!

I would give this book 4 stars, but because of the obnoxious writing style I rate it as 3 stars.

 
Share your thoughts with other customers
Create your own review