June 24, 2007
Exploring Ruby Metaprogramming
"What is so important about Ruby as the language that underpins the Rails framework?"
It's an important question to answer. After all, one of the early responses to Rails in the Java community was an attempt to build a similar framework in Java. I think it's fair to say that Trails has not achieved significant traction.
So what's so special about Ruby? The answer would appear to be metaprogramming or, to express it another way, the dynamic power of the language. It is an aspect of Ruby that I'm currently exploring in order to feel that I have a better grasp of how Ruby's features are key to enabling the power of Rails.
In conjunction with delving into the Rails source code looking for uses of methods such as class_eval, method_missing and define_method, I'm currently carefully reading chapter 13 of David A. Black's book "Ruby for Rails". This chapter is devoted to what David calls "Ruby dynamics". It deals with characteristics such as singleton classes, the eval family of methods, callable objects, callbacks and hooks and overriding and adding to core functionality.
So that's what I'm currently exploring in Ruby. Soon I hope to be in a position to write about examples of how Ruby metaprogramming is used within Rails.
Posted to Rails by Keith PittyIt's almost unfortunate that Trails was named as it is. Java's answer to Rails is Grails; Trails is much closer to Naked Objects framework in its ideology, and as such rather different from Rails.
Posted by: Kalle Korhonen at August 8, 2007 6:28 PM
