Tim Bray (Sun Microsystems) on Ruby

X

Xavier Noria

The Director of Web Technologies at Sun Microsystems jumps directly to
the conclusion about Ruby. "For people like me, who are proficient in
Perl and Java, Ruby is remarkably, perhaps irresistibly, attractive."
http://www.tbray.org/ongoing/When/200x/2006/07/24/Ruby

Just for the archives, at the end of the post it reads:

"Finally, a minor, almost a footnote, issue. I miss polymorphism. In
particular, I miss polymorphic constructors."

but Ruby does have polymorphism. I guess he means "method
overloading" (which can be partially mimicked with default arguments).

-- fxn
 
B

Bob Hutchison

Hi,

Just for the archives, at the end of the post it reads:

"Finally, a minor, almost a footnote, issue. I miss polymorphism.
In particular, I miss polymorphic constructors."

but Ruby does have polymorphism. I guess he means "method
overloading" (which can be partially mimicked with default arguments).

I'm pretty sure he means 'ad hoc polymorphism' which is, within half
the width of a hair, the same as 'overloading'... though, it does say
something about his world view. This is one of the only places where
types/classes are used in CLOS, at least when I write in CLOS. Though
I love working in Ruby and I understand why Ruby doesn't support it,
I too miss this on occasion.

Cheers,
Bob

----
Bob Hutchison -- blogs at <http://www.recursive.ca/
hutch/>
Recursive Design Inc. -- <http://www.recursive.ca/>
Raconteur -- <http://www.raconteur.info/>
xampl for Ruby -- <http://rubyforge.org/projects/xampl/>
 
F

Francis Cianfrocca

What I find myself becoming more and more comfortable with is passing
single hashes to methods that take more than one argument, and single
arguments whenever possible. (And yes, I started doing this long
before the recent thread on functional programming :), much of
Net::LDAP works this way). I find this to be a perfectly natural
alternative to polymorphic method signatures (even though the Python
syntax for this technique is better than Ruby's).

As far as Tim's polymorphic constructors go, I also find myself
avoiding constructors as much as possible in the first place. If you
have initial state in an object, that means it's been designed (or
not-so-designed as the case may be) in a non-composable way. My recent
Ruby code has almost no inheritance and module mixins all over the
place.
 
J

James Edward Gray II

Just for the archives, at the end of the post it reads:

"Finally, a minor, almost a footnote, issue. I miss polymorphism.
In particular, I miss polymorphic constructors."

but Ruby does have polymorphism. I guess he means "method
overloading" (which can be partially mimicked with default arguments).

Hmm, I would say you would mimic this by accepting any number of
arguments:

def initialize(*args)
if # check args.size and type...
init_with_whatever(*args)
elsif # check args.size and type...
init_with_whatever_else(*args)
else
raise ArgumentError, "#{args.inspect} not a supported call."
end
end

You could generalize this into a library, of course, and I'm pretty
sure people have.

James Edward Gray II
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top