Monday, December 7, 2009

A Ruby book worth reading for Pythonistas

It's been a while since I've ready an entire technical book over the weekend. But I enjoyed Design Patterns in Ruby so much that I kept picking it up for "one more chapter".

I played with Ruby a little several years ago, but I've never used it seriously. I need to use it at work though. Specifically, I wanted to learn about creating Domain-Specific Languages (DSLs) in Ruby, which is what led me to this book (since it has a chapter on DSLs).

When the book arrived late Thursday I skipped straight to the DSL chapter, which was interesting. But then I started reading it from the beginning. Chapter 1 talks about design patterns, the book Design Patterns, and the general principles that begin the Gang of Four book:
  • Separate out the things that change from those that stay the same.
  • Program to an interface, not an implementation.
  • Prefer composition over inheritance.
  • Delegate, delegate, delegate.
Russ Olsen adds "You ain't gonna need it."

Chapter 2 is a concise introduction to Ruby: just 37 pages. It's not thorough, but it's enough to be able to read the Ruby code in the subsequent chapters.

Chapters 3 through 15 explain many of the patterns covered in the Gang of Four book. I enjoyed brushing up on my patterns, but what kept me wanting to read "one more chapter" over the weekend was how after explaining the pattern, Olsen explains how it does or does not apply in Ruby. And he takes the opportunity to introduce Ruby features (like procs & blocks, modules and mixins, modifying classes and objects on the fly, message passing, etc.) as he does this.

He also write about how each pattern can be abused, and describes real-world uses of the patterns in the Ruby libraries.

Chapters 16 through 18 describe three "patterns that have emerged with the introduction and expanded use of Ruby": DSLs, meta-programming and convention over configuration. And there are two appendices: A on installing Ruby on different platforms, and B contains a carefully annotated bibliography.

I suspect I'll find myself referring back to this book often, even when I'm writing Python code. I suspect reading it will help make me a better Python programmer (and a better programmer in general). So I recommend it.

If I had loads of time, it would be a worthwhile exercise to go through each pattern in the book and convert the examples to Python, and look for examples of the pattern in the Python libraries. I wonder if anyone else with more time has already had this idea.

43 comments:

日戲風格 said...
This comment has been removed by a blog administrator.
睡衣 said...
This comment has been removed by a blog administrator.
ispomyju said...
This comment has been removed by a blog administrator.
119 said...
This comment has been removed by a blog administrator.
hh1y5t65 said...
This comment has been removed by a blog administrator.
qust said...
This comment has been removed by a blog administrator.
wfrrqrtw said...
This comment has been removed by a blog administrator.
婉婷婉婷 said...
This comment has been removed by a blog administrator.
陳志其 said...
This comment has been removed by a blog administrator.
NylaWoodcock0502 said...
This comment has been removed by a blog administrator.
BrookV22988 said...
This comment has been removed by a blog administrator.
昱宏 said...
This comment has been removed by a blog administrator.
雲亨 said...
This comment has been removed by a blog administrator.
ac21f2d2 said...
This comment has been removed by a blog administrator.
淑婷 said...
This comment has been removed by a blog administrator.
重俐 said...

pleasure to find such a good artical! please keep update!!

Tro0223y_Millan said...
This comment has been removed by a blog administrator.
730A_ngelinaRabideau0 said...
This comment has been removed by a blog administrator.
Is依來raelS_Fargo0706依來 said...
This comment has been removed by a blog administrator.
esthermelvin said...
This comment has been removed by a blog administrator.
誠紋 said...
This comment has been removed by a blog administrator.
哲維維 said...
This comment has been removed by a blog administrator.
許紀廷 said...
This comment has been removed by a blog administrator.
淑娟淑娟 said...
This comment has been removed by a blog administrator.
恩如 said...
This comment has been removed by a blog administrator.
江冠彭珮李佳宏陽筠 said...
This comment has been removed by a blog administrator.
竹青 said...
This comment has been removed by a blog administrator.
劉耀德劉耀德 said...
This comment has been removed by a blog administrator.
陳韋夏陳韋夏益東富益東富 said...
This comment has been removed by a blog administrator.
蔡靜芳蔡靜芳 said...
This comment has been removed by a blog administrator.
ju吳phe宇te佳ns said...
This comment has been removed by a blog administrator.
RicoLisi0802志竹 said...
This comment has been removed by a blog administrator.
v彥伶林 said...
This comment has been removed by a blog administrator.
文王廷 said...
This comment has been removed by a blog administrator.
建邱勳 said...
This comment has been removed by a blog administrator.
建邱勳 said...
This comment has been removed by a blog administrator.
佳陳容 said...
This comment has been removed by a blog administrator.
陳李原筠永辛 said...
This comment has been removed by a blog administrator.
麗王王珠 said...
This comment has been removed by a blog administrator.
于庭吳 said...
This comment has been removed by a blog administrator.
佳張張張張燕張張張張張 said...
This comment has been removed by a blog administrator.
蕾蕾 said...
This comment has been removed by a blog administrator.
159fsaf said...
This comment has been removed by a blog administrator.