Whose Variable Is It Anyway?

Posted by Rick DeNatale Fri, 08 Feb 2008 21:14:00 GMT

The more I think about Ruby in relation to other object programming languages I’ve worked with, the more I realize that there’s a continuum of static vs. dynamic typing.

Ruby fits close to one end of that continuum. Understanding this can help understand how to best use the language. I recently had a quick look at Russ Olsen’s new book Design Patterns in Ruby and looked at his section on the observer pattern. I’d just posted to ruby-talk about this pattern, how it was implemented in Smalltalk, and a more Rubyish implementation. I’ll get to that at the end of this article, but first I really feel the urge to talk about instance variables.

If we view a type as a particular interpretation of a memory layout, I see something like this

Language Outside inside
Java static static
Smalltalk encapsulated static
Ruby encapsulated dynamic
Read more...

Posted in ,  | Tags , ,  | 3 comments | no trackbacks