Book Recommendation: Ruby Under a Microscope

When I started Ruby, I wanted to learn the language in some real depth. I asked a few coworkers, “What is the C# In Depth of Ruby?” Eventually, someone recommended Ruby Under a Microscope. This book helps me see through some Ruby magic and understand a little bit better. Scott Hanselman recently posted that some people learn from the metal up, wanting to understand CPUs and compilers, and some people learn from the glass back, making something the user can see, then tackling technical details as needed. I am definitely a metal-up learner, and Ruby Under a Microscope is definitely a metal-up book. There are almost as many code samples in Ruby bytecode as in Ruby.

I picked up the book because I kept making little syntax errors in Ruby; C# and JavaScript had so conditioned me to put parens and curly braces everywhether that I kept typing the wrong thing in Ruby. After reading Ruby Under a Microscope, I know something about the C code Ruby executes to make the closure representing a block. The book definitely has some real depth to it.

One of the real benefits of reading this book is that it gives me a shot at reasoning about Ruby abstractions when they leak. For example, if I include a module in a class, and then later define a new method on the module, can the class see the new method? What if I later include another module in the module, can the class see the new module’s methods? These questions are hard to reason about from inside Ruby (and frankly, if your code depends on the answer to these questions, you may want to refactor), but being able to give a reasoned answer to these questions from the behavior of the language makes me feel much better about working in Ruby. (The answers are: yes, the class sees new methods, but no, the class doesn’t see new modules.)

The book felt like it was right at my level: I love languages, and I am bit of a nerd about syntax edge cases and type systems and whatnot, but I don’t have a CS degree, so I never had a class where I wrote my own compilers. Ruby Under a Microscope didn’t assume so much CS knowledge that I couldn’t follow it, nor did it hand-wave over so much detail that I got bored.

Also, I’d like to plug the writing. I was taking notes as I read, and I often wrote down a question only to have the question answered by the very next paragraph. Presenting abstract information in a coherent flow of thought is challenging, so props to Pat Shaughnessy for that.

I definitely recommend the book, especially if you liked C# In Depth and want some Ruby knowledge, or if you’re new to Ruby but not new to programming, and things like metaprogramming seem a little bit magical because you come from a language doesn’t do such explicit self-manipulation.

That’s all for this week. Till next time, happy learning!

-Will

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s