Heya,
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/78502
is now a bit older than four years
Bit long, sorry, my “real” question is on the bottom of
this … anyway
I think i get that with duck typing you dont care what
class/type something is. You ask it if it reponds_to?
something (and thus has a method)
It sounds a bit as if classes become less important than
behaviour (i think that’s a good notion anyway) and
is thus a lot more flexible in general. So far so fine.
When I lately asked on an IRC channel for a prototype based
language, I unfortunately didn’t really get the answer I hoped
for (how that language handled “duck typing”) but actually
it was quickly pointed out that duck typing is used in other
languages a lot too, maybe with different names )and for
static languages with a bit more rigid structure).
One definition that kept up was “late bound” (I admit freely,
duck typing would be approximately 100x easier to understand
than “late bound”, IF this refers to the same concept)
Smalltalk and Self would be examples for late bound concept.
Java has dynamic class loading and virtual calls (checked at
class loading time and checked on interfaces) but it seems
very rarely used (and, it seems you have to do a new
abstract class? How strange is this to create a totally
new class just to get to this behavioural concept?? But
then again I may be totally wrong )
Basically it seems to boil down (for me) to message sends
and a class/type “less” approach where the object just
adapts to a job, instead of satisfying a compiler…
Ok now to my question!
What is the difference between ruby’s approach to classes
and duck typing compared to prototype based languages which
seem to have an even looser model (i.e. a less rigid class
vs object distinction and their usage of prototypes
“adapting” to a problem from the “bottom-up” ?)
Ah and if I forgot something about duck typing or similar
in other languages - maybe its interesting - please someone
feel free to point that out!