Inheritance structure less important in dynamic languages?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Marvin

    #1

    Inheritance structure less important in dynamic languages?


    Hi,

    It's been claimed that inheritance structures are less important in dynamic
    languages like Python. Why is that and where can i read more about that?

    /Marv
  • Ben Finney

    #2
    Re: Inheritance structure less important in dynamic languages?

    "Marvin" <marv@mailcity. com> writes:
    [color=blue]
    > It's been claimed that inheritance structures are less important in
    > dynamic languages like Python.[/color]

    Who claimed that? I ask not because I doubt your assertion ("it was
    claimed"), but rather that if someone claimed something, it seems
    better to ask that person your next question:
    [color=blue]
    > Why is that and where can i read more about that?[/color]

    The person who claimed it is more likely to be able and willing to
    defend it.

    --
    \ Eccles: "I just saw the Earth through the clouds!" Lew: "Did |
    `\ it look round?" Eccles: "Yes, but I don't think it saw me." |
    _o__) -- The Goon Show, _Wings Over Dagenham_ |
    Ben Finney

    Comment

    • bruno at modulix

      #3
      Re: Inheritance structure less important in dynamic languages?

      Marvin wrote:[color=blue]
      > Hi,
      >
      > It's been claimed[/color]

      s/claimed/observed/

      In Python and Ruby, class hierarchies tends to be *really* flat when
      compared to Java or C++.
      [color=blue]
      > that inheritance structures are less important in dynamic
      > languages like Python. Why is that[/color]

      Don't you guess ?-)

      A very obvious point is that in a dynamically typed language,
      inheritence is only about implementation - it's not used for class-based
      polymorphism (subtyping).

      Also, dynamic languages are usually very strong on introspection and
      offer good support for automatic delegation ("DoesNotUnders tand" in
      Smalltalk, __getattr__ in Python, etc), which tend to lower the use of
      inheritence for "private inheritence" (ie: implementation reuse without
      any subtyping semantic).

      This leaves with only three real use-case for inheritence :
      * factoring common features of a set of related classes in an abstract
      base class
      * specialisation of an existing class (proper subclassing),
      * mixins.
      [color=blue]
      > and where can i read more about that?[/color]

      "duck typing", "implied interface" and "compositio n/delegation" could be
      good starting points for a google search.

      --
      bruno desthuilliers
      python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
      p in 'onurb@xiludom. gro'.split('@')])"

      Comment

      Working...