[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Ruby and OO (fwd)

   Date: 29 Nov 2001 14:57:48 -0500
   From: Bruce Lewis <brlewis@alum.mit.edu>

   I'd like to point out that what makes the Ruby syntax convenient is that
   it does not force the programmer to think in OO terms.  Even if the
   block { |i| puts(i) } is implemented as some kind of object, from the
   programmer's perspective it's just a function.  There's no need to
   establish a package/object/method/statement/expression hierarchy as in

The implication that Java's object-orientation forces you to create a
five-level deep hierarchy of some kind, in order to do anything, is
misleading at best.  Rhetorical overkill is unnecessary.  What there's
no need to do in Ruby is establish a class/method two-level hierarchy
as in Java.  I think that's as much as you need to make the (perfectly
valid) point you want to make.

But, as I said before, in Common-Lisp-with-CLOS (and, if memory serves
at all, Dylan), you don't have to create a class in order to write a
simple procedure, either, even though the object-orientation is really
quite fundamental.

One way to think of it is that the basic idea is to generalize the
multi-methods idea.  The multi-methods idea is that you can have a
method that is chosen by the class of *two* or *more* arguments,
instead of just *one*.  The generalization is that *zero* is OK too.
So (defun double (x) (+ x x)) is a multimethod with zero
type-discriminated parameters.  So we do not create a language with
two facilities: (1) functions, and (2) methods, but just one facility.

-- Dan