2010/02/06

I love Metaprogramming Ruby so much.

Why...
If I'd like to tell my significant other of my feeling, I can write the code like this 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 more straightforward and simpler.

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

Since I saw this code, I've fallen in love with Ruby.
After that, I've been enjoying reading tutorials and blogs on the Internet which taught me interested Ruby tips and tricks. But I have always something on my chest.... It's the Metaprogramming.

I've read the articles about Metaprogramming, but unfortunately I didn't understand them very well. Everyone says Metaprogramming is an advanced technique. So I saied to myself that it's too early for me.

Then I met this book luckily. I started reading the introduction and the story about Bob and Bill.... Oh, 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 the real project and adds some explanations. I don't understand them very well on my first reading, but after reading and reading and trying to run the code again and again, I feel I'm growing up gradually.

Auther Paolo says the following in the interview at RubyLearning.org: 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 of course. But I'm dreaming with this book. :)

ashbb

-------
Note: This is a translation of the review for Metaprogramming Ruby on Amazon.co.jp.

1 comment:

phoet said...

it's not just the meta programming. there is a lot more that beauty in ruby that needs to be caressed.

have a look at the latest article i wrote about DSLs: http://blog.nofail.de/2010/02/writing-your-own-dsl-with-ruby/

O'Reilly Ruby Books

Twitter Updates

    follow me on Twitter