News for hackers. Stuff that matters.
Re:Why inheritance sucks by rimantas on Friday August 20, 2010 @09:38AM (#1620337)
The other reason as I see is some quite weird perception that OOP == inheritance.
Re:Why inheritance sucks by samg_ on Friday August 20, 2010 @10:00AM (#1620386)
OOP is different things to different people. While I agree with you that OOP != inheritance, I believe that polymorphism ∈ OOP and inheritance is a part of polymorphism.
Re:Why inheritance sucks by vog on Saturday August 21, 2010 @09:28AM (#1622796)
I disagree. Polymorphism and inheritance are separate concepts.

Yes, some statically typed languages like C++ and Java enforce certain inheritance constraints via classes or explicit interfaces before you can use polymorphism.

But almost all dynamically typed languages allow for ad-hoc polymorphism. For instance, in Python this is called "duck typing". Just because two objects provide a "foo()" method doesn't mean they are in any inheritance relation to each other. But polymorphism should still work.

Re:Why inheritance sucks by loup-vaillant on Friday August 20, 2010 @10:06AM (#1620400)
I don't follow you here. Are you saying that inheritance is mandatory to OOP? (I don't agree nor disagree. I'd just like to know what you mean.)
Re:Why inheritance sucks by samg_ on Friday August 20, 2010 @11:07AM (#1620575)
I am not saying that inheritance is mandatory to OOP. I think "mandatory" is too strong of a word here. As I said, OOP means different things to different people and I am okay with that.

Speaking for myself, OOP is a way to orchestrate programming on a large scale. To grow software without growing the frequency, severity, and difficulty of bugs and without growing costs associated with new features is the desired result. Component-ized architecture takes great steps to achieve this result. For this reason, I view OOP as being some combination of: message passing, encapsulation, and polymorphism. I do not believe this is a complete view of OOP, nor that there is no viable alternative view of OOP.

Re:Why inheritance sucks by barrkel on Friday August 20, 2010 @10:19AM (#1620430)
Polymorphism is often implemented as at least inheritance of interface in statically typed languages. Without polymorphism you don't get dynamic dispatch, especially open to extension at runtime.
Re:Why inheritance sucks by tkahn6 on Friday August 20, 2010 @11:04AM (#1620566)
Ad hoc polymorphism ∈ OOP

Parametric polymorphism ∈ FP

Re:Why inheritance sucks by loup-vaillant on Friday August 20, 2010 @09:57AM (#1620375)
Quite right. We can correct that by showing the classification of main programming paradigms[1]. It shows that, OO just needs records, procedures, named state and closures. (I personally prefer to say the more understandable "OO needs structs, assignment, and closures".)

Now I have a problem, however: what is the difference between OO and stateful functional programming?

[1]: http://www.info.ucl.ac.be/~pvr/paradigms.html

Re:Why inheritance sucks by barrkel on Friday August 20, 2010 @10:15AM (#1620420)
Polymorphism is at the core of most OO language features. Sum types aren't a viable substitute in most large apps because they are closed to extension at runtime. Doing it right functionally means rolling your own protocol system.