News for hackers. Stuff that matters.
Re:If Inheritance is so bad, why does everyone use it? by eddd-ddde on Thursday April 11, 2024 @02:48PM (#40005457)
Except inheritance is the premature optimisation of interfaces.

Inheritance forces you to define the world in terms of strict tree hierarchies, which is very easy to get wrong. You may even do a great job today, but tomorrow such properties don't hold anymore.

Regular composition allows the same functionality without making such strong assumptions on the data you are modelling.

Re:If Inheritance is so bad, why does everyone use it? by sameoldtune on Thursday April 11, 2024 @02:51PM (#40005498)
Arborescent vs rhizomatic approaches, to get philosophical.
Re:If Inheritance is so bad, why does everyone use it? by 082349872349872 on Thursday April 11, 2024 @03:57PM (#40006169)
Unfortunately Deleuze's The Fold has little to say about either awk or catamorphisms.
Re:If Inheritance is so bad, why does everyone use it? by dragonwriter on Thursday April 11, 2024 @05:50PM (#40007199)
> Inheritance forces you to define the world in terms of strict tree hierarchies,

No, it doesn’t.

Inheritance is the outcome of deciding to model some part of the problem space with a tree hierarchy (that potentially intersects other such heirarchies). It doesn’t force you to do anything.

I suppose if there was a methodology which forced you, as the only modeling method, to exclusively use single inheritance, that would force you to do what you describe, but…that’s not inheritance, that’s a bunch of weird things layered on top of it.

Re:If Inheritance is so bad, why does everyone use it? by eddd-ddde on Friday April 12, 2024 @01:03PM (#40015163)
It may not force you directly, but I think it's safe to say that when a language focuses on inheritance (e.g. c++) it does not offer good alternatives (e.g. rust traits). This means that if you want features such as runtime polymorphism, you are _kinda_ forced into inheritance.
Re:If Inheritance is so bad, why does everyone use it? by EVa5I7bHFq9mnYK on Friday April 12, 2024 @04:50AM (#40010596)
True. Modelling the world as a tree oversimplifies it, as there are also lateral and even backwards dependencies, and at a sufficiently complex level abstractions start to leak all over, making it a mess. But at some low to medium level of complexity it might work.