Hi --
Hi,
I have been reading a WikiPedia piece on Minimalist Computing (http://
tinyurl.com/6h83b3). Could we argue that Ruby is a minimal language?
That's a very interesting question. I would say: yes and no.
The "no" part is, I think, manifest in the fact that you can achieve
similar ends by different routes, and also perhaps in the fact that
there are methods with more than one name. And all that "Python vs.
Perl" stuff that seems to me, increasingly, irrelevant to Ruby (or
maybe just shop-worn and boring).
The "yes" part is more interesting. I've always been fascinated by the
way that Ruby creates what appear to be language-level features,
simply by recombining existing features. The best example is probably
the attr_* family of methods. We speak of "attributes" in Ruby, but
all that's going on is that there are some methods -- macros, as it
were -- that create other methods that wrap instance variables. The
instance variable is a language-level construct, and so are methods.
But the "attribute" simply floats on top of those constructs.
I don't think this means that Ruby is really minimalist; but it does
mean that Ruby uses minimalist principles in very interesting ways.
Another example is class methods. Class methods are basically just
singleton methods on class objects. (Except for one way in which
they're special-cased, namely that subclasses can call their
superclass's class methods.) Ruby already has singleton methods, and
classes are already objects. All you have to do is put the pieces
together.
It's as if Ruby is saying, "You want 'attributes'? You want 'class
methods'? Sure -- go ahead!" Of course, the core language itself does
incorporate these things. But they're built on existing components of
the language.
In that sense, I think that Ruby has a way of taking on the features
of whoever is using it. Of course it has its own style and
architecture. But it's so easy to add features, and to see almost
mirage-like language features even when they're not really there. I've
always said that the biggest issue most people face when learning Ruby
is that the language is simpler than they can believe. Attributes are
certainly a good example of that; I've seen a lot of people struggling
because they're trying too hard to see some identity that isn't there
between, say, instance variables and attributes. The idea that it's
just a bunch of methods that do very, very simple things is in some
ways harder to grasp than something more elaborately engineered would
be (but I'm glad it isn't!
David
--
Rails training from David A. Black and Ruby Power and Light:
INTRO TO RAILS June 9-12 Berlin
ADVANCING WITH RAILS June 16-19 Berlin
INTRO TO RAILS June 24-27 London (Skills Matter)
See
http://www.rubypal.com for details and updates!