Eric Mahurin
8/29/2007 1:35:00 PM
On 8/29/07, Marc Heiler <shevegen@linuxmail.org> wrote:
> 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!
Another place I've noticed similar functionality is with
templates/generics in C++/Java. You write code that doesn't care
about the (template/generic) classes/types. You write code for
objects of template/generic classes that respond to a set of methods
that you use. Compared to duck-typing in ruby, the main difference is
that concrete classes that you want to use for these template/generic
classes must be determined at compile-time. And of course
template/generic code is extremely ugly because it has to look like
static typing even those the types are variable. Also, with
template/generic code, the code is replicated for each class/type
combination, where with duck-typing this is not needed since finding
the methods occurs at run-time.