Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Duck typing" etymology? [closed]

Tags:

duck-typing

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?

like image 807
Jeffrey Aylesworth Avatar asked Dec 04 '09 04:12

Jeffrey Aylesworth


People also ask

Why is duck typing called duck typing?

Duck typing in computer programming is an application of the duck test—"If it walks like a duck and it quacks like a duck, then it must be a duck"—to determine whether an object can be used for a particular purpose.

What is the difference between duck typing and inheritance?

With duck typing you can introduce subtle bugs in your code due this lack of formal relationship. If your "quack" isn't a "quack" at all, you'll be in trouble. With inheritance, this is less likely to happen due the contractual nature of subclassing abstract classes.

Is duck typing a form of touch typing?

The term Duck Typing is a lie.

What is a duck typed language?

Duck Typing is a way of programming in which an object passed into a function or method supports all method signatures and attributes expected of that object at run time. The object's type itself is not important. Rather, the object should support all methods/attributes called on it.


2 Answers

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

like image 169
Jonathon Faust Avatar answered Oct 29 '22 11:10

Jonathon Faust


http://groups.google.com/group/comp.lang.python/msg/e230ca916be58835?hl=en&

Alex is involved... ;)

like image 28
Stefano Borini Avatar answered Oct 29 '22 10:10

Stefano Borini