… of many things …

… of many things … header image 2

Meta-Programming in Smalltalk vs. Ruby

September 8th, 2007 · 1 Comment

I am both a Rubyist & a Smalltalker. I enjoy both environments immensely and use them for different purposes. In a recent flurry of posts, James Robertson over at Cincom completely misunderstood the point Neal Ford was making about the meta-programming facilities Ruby offers versus the facilities Smalltalk offers, or better yet the facilities that either tend to use.

Avi Bryant chimed in and cleared the picture up a bit, but I wanted to simplify it even further for those who are still in the dark. Mind you, I do mean simplify.

The issue as I see it is the ability and/or desire to add methods to an instance of an object, rather to its class definition. (I know that you can probably do this in Smalltalk, but I don’t know how.) The beauty of meta-programming this way is that we can add a ton of very useful boiler-plate code to an object without cluttering its definition, and the implementation of the new method isn’t reflective (thus adding performance penalties).

In a language like Ruby this is key, where the tools are less than capable, and we are still dealing with “source code in files, how quaint” (Kent Beck). In Smalltalk it doesn’t matter so much that the code is generated into the class definition, because we don’t browse code in Smalltalk the way we might in Ruby.

Of course there are other arguments about why meta-programming this way is good or bad, but I think this is the main point of the discussion at hand.

Someone feel free to correct me if I have been too simplistic.

Tags: Computing · Software · Ruby · Smalltalk

1 response so far ↓

  • 1 Catherine // Sep 8, 2007 at 11:07 pm

    Thanks, that helped. I was getting lost.

    Gravatar:

Leave a Comment