Hacker News new | past | comments | ask | show | jobs | submit login

For any struggling to understand Ruby's metaprogramming, the rather short and succinct Metaprogramming Ruby is an excellent read. There's a method to the madness of define_method, method_missing, the various eval methods, the difference between Blocks, Procs, and Lambdas. Most of it revolves around manipulating scopes.

It also shows how you can iterate from the ugliest, most powerful, most dangerous eval method by pulling out the functionality you need into less-powerful, safer manipulations. It's all Ruby code until it's actually executed, so it can all be manipulated at runtime.


Yup this is great stuff, just be sure to get the 2nd edition which just came out:


It focuses on modern Rubies, so it talks about Module#prepend and such. Nice to keep moving forwards.

Seconding. The book revolutionized my understanding of Ruby, and inspired me to create a whole visual novel framework: https://github.com/thirdtruck/rubyai.

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact