Wanted: Citation supporting Duck Typing

Discussion in 'Python' started by Paddy, May 9, 2008.

  1. Paddy

    Paddy Guest

    Hi,
    The wikipedia article on Duck Typing has this criticism section that
    needs a citation:
    (Fron: http://en.wikipedia.org/wiki/Duck_typing#Criticism)

    An often cited criticism is this:
    One issue with duck typing is that it forces the programmer to
    have a much wider understanding of the code he or she is working with
    at any given time. In a strongly and statically typed language that
    uses type hierarchies and parameter type checking, it's much harder to
    supply an unexpected object type to a class. For instance, in python,
    you could easily create a class called Wine, which expects a class
    implementing the "press" method as an ingredient. However, a class
    called Trousers might also implement the press() method. With Duck
    Typing, in order to prevent strange, hard to detect errors, the coder
    needs to be aware of each potential use of the method "press", even
    when it's conceptually unrelated to what he or she is working on. With
    type checking and hierarchical type declarations, all wine ingredients
    would be subclasses of WineIngredient or something like that, negating
    the problem.

    In essence, the problem is that, "if it walks like a duck and
    quacks like a duck", it could be a dragon doing a duck impersonation.
    You may not always want to let dragons into a pond, even if they can
    impersonate a duck.

    In practice, the issue is equivalent to not mixing dissimilar objects
    for duck-typing and is handled almost transparently as part of the
    knowledge of the codebase required to maintain it.[citation needed]


    I've only found this so far as a citation:
    http://jessenoller.com/2007/05/30/typeducking-on-duck-vs-static-typing/
    Whilst it is good, do you know any other work that refutes the
    criticism?

    (I, and many others don't see the problem, but who has written about
    it).

    Thanks, Paddy.
     
    Paddy, May 9, 2008
    #1
    1. Advertising

  2. Paddy

    Paddy Guest

    On May 9, 6:30 pm, Paddy <> wrote:
    > Hi,
    > The wikipedia article on Duck Typing has this criticism section that
    > needs a citation:
    > (Fron:http://en.wikipedia.org/wiki/Duck_typing#Criticism)
    >
    > An often cited criticism is this:
    > One issue with duck typing is that it forces the programmer to
    > have a much wider understanding of the code he or she is working with
    > at any given time. In a strongly and statically typed language that
    > uses type hierarchies and parameter type checking, it's much harder to
    > supply an unexpected object type to a class. For instance, in python,
    > you could easily create a class called Wine, which expects a class
    > implementing the "press" method as an ingredient. However, a class
    > called Trousers might also implement the press() method. With Duck
    > Typing, in order to prevent strange, hard to detect errors, the coder
    > needs to be aware of each potential use of the method "press", even
    > when it's conceptually unrelated to what he or she is working on. With
    > type checking and hierarchical type declarations, all wine ingredients
    > would be subclasses of WineIngredient or something like that, negating
    > the problem.
    >
    > In essence, the problem is that, "if it walks like a duck and
    > quacks like a duck", it could be a dragon doing a duck impersonation.
    > You may not always want to let dragons into a pond, even if they can
    > impersonate a duck.
    >
    > In practice, the issue is equivalent to not mixing dissimilar objects
    > for duck-typing and is handled almost transparently as part of the
    > knowledge of the codebase required to maintain it.[citation needed]
    >
    > I've only found this so far as a citation:
    > http://jessenoller.com/2007/05/30/typeducking-on-duck-vs-static-typing/
    > Whilst it is good, do you know any other work that refutes the
    > criticism?
    >
    > (I, and many others don't see the problem, but who has written about
    > it).
    >
    > Thanks, Paddy.


    A bit more searching gives me:

    http://hans.fugal.net/blog/articles/2006/07/08/duck-typing-defended
    And:
    http://www.mindview.net/WebLog/log-0025

    I don't have a collection of Dynamic language books though.

    - Paddy.
     
    Paddy, May 9, 2008
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Duck Typing

    , Sep 16, 2003, in forum: Python
    Replies:
    10
    Views:
    687
    Steve Holden
    Sep 17, 2003
  2. Replies:
    15
    Views:
    572
    Isaac Gouy
    Sep 1, 2006
  3. Replies:
    2
    Views:
    323
    Terry Reedy
    Jan 28, 2008
  4. Paddy
    Replies:
    0
    Views:
    242
    Paddy
    Jun 25, 2008
  5. Jose Mora

    duck typing at will

    Jose Mora, Dec 30, 2008, in forum: Python
    Replies:
    1
    Views:
    274
    Bruno Desthuilliers
    Dec 30, 2008
Loading...

Share This Page