OOP inheritance gets a lot of flack because it was the first iteration of a principle that we're still trying to figure out: how to create syntactic relationships between things and infer properties from them. Inheritance being "these are the same EXCEPT these differences"
Inheritance inspired a lot of followup work, leading to ADTs, Parnas modules, typeclasses. Notably all of these relate to different "things" that are lower on the abstraction hierarchy: there's a gulf between the relationship construct and the value types it relates to
The same isn't true in inheritance: there's nothing stopping you from inheriting `Duckling` from `Duck`, even though `Duck` can be directly instantiated. Originally this was seen as a good thing, as it made it easy to share both type and implementation details.
It's not a priori obvious that this causes problems, but it's much more evident now: that's what the D in SOLID is for. There's lots of alternatives in OOP now, too, like interfaces and ABCs, which address the "same abstraction level" issue
The other dominant alternative is to "prefer composition over inheritance", which works in a different way. It allows arbitrary relationships but infers nothing about them. You know A is connected to B, but anything about A, B, the connection, or even if B is connected to A
But none of these things give *quite* the same depth of power, and danger, as inheritance, which is still used when nothing else fits appropriately. That makes inheritance kinda like goto: something that's too powerful to use as the primitive, we need to build on top of it
But unlike goto we don't have a full set of things that properly replace inheritance. I think there's still a lot more "syntactic relations" waiting to be discovered that could usefully and expressively augment the existing ones we have
One interesting example is BETA, which had "inner" relationships. The superclass methods had some behavior and a customizable `inner` block to fill in, all the subclass can do is specify what the `inner` looked like. Kinda like block templating systems
(BETA is an interesting failed path in OOP, a bunch of great ideas for semantics crushed under an absolutely terrible syntax. Most of the ideas haven't been examined since.)
I think there was also some interesting stuff happening with Aspect-Oriented Programming and objects, though the entire development world seems to have dropped AOP in a well and boarded it up. Get serious "this is not a place of honor" vibes from AOP, honestly kinda spooky.
Don't actually have a grand unifying conclusion here, I just enjoy thinking about this stuff
Also I expect either Eiffel devs or CLOS devs to excitedly tell me about aspects of their object systems I haven't covered, like contract-inheritance or however CLOS works
You can follow @hillelogram.
Tip: mention @twtextapp on a Twitter thread with the keyword “unroll” to get a link to it.

Latest Threads Unrolled: