views:

191

answers:

4

Is there a story behind the name ''duck typing'', I've heard ''if it looks like a duck, and sounds like a duck, let's call it a duck'' (or something like that), but why a duck? Why not ``if it looks like a _ and sounds like a _, let's call it a _''.

It sounds like a Flying Circus sketch, but I don't remember it. Is there a story behind the name?

+7  A: 

Duck typing is a phrase borrowed from the much older "walk like a duck". The latter has been around far longer than the programming idea it describes. See answerbag.com

Jonathon
+2  A: 

This is not really a programming question, but my guess: Ducks walk funny and they quack. This is amusing enough to turn it into a figure of speech. :-)

asveikau
A: 

No, the analogy is that if a variable looks like an integer (for example), and acts as an integer, it must be an integer (type).

Duck typing means 'no explicit predeclaraction of type'.

pavium
I get that, but I'm wondering why duck, of all possible choices
Jeffrey Aylesworth
well, as everyone agrees, we know the expression about ducks, it's been around for a while. Possibly, the characteristics of a ducks *easily* distinguishes it from other waterfowl. The story of the Ugly Duckling must be the exception which proves the rule.
pavium