News for hackers. Stuff that matters.
Re:Classes Considered Harmful [pdf] by codr4life on Tuesday January 03, 2017 @03:27PM (#13312733)
Why do we need inheritance? Embedding and delegating can handle any task but the silly ISA pretend game.
Re:Classes Considered Harmful [pdf] by recursive on Tuesday January 03, 2017 @03:52PM (#13312973)
Embedding and delegating don't deal very well with virtual dispatch afaik. Declaring different implementations for arbitrary sub-classes seems harder and less elegant without inheritance.
Re:Classes Considered Harmful [pdf] by codr4life on Tuesday January 03, 2017 @04:14PM (#13313168)
But virtual dispatch is trivial to add where you actually need it, a bunch of function pointers in a struct and you're good to go. And once you stop viewing the world through the OOP filter there aren't that many real hierarchies and interfaces left to deal with. The curse of OOP is that it turns problem solving into day dreaming, with expected results.
Re:Classes Considered Harmful [pdf] by recursive on Tuesday January 03, 2017 @08:54PM (#13315050)
OOP isn't the solution to every problem. Your proposed replacement to inheritance would would work nicely in some cases. As far as I can tell, it doesn't address the use case of generic classes at all, at least in a type-safe way.
Re:Classes Considered Harmful [pdf] by codr4life on Wednesday January 04, 2017 @02:37AM (#13316420)
Generics and OOP are orthogonal, one does not depend on the other. So let's say you declare your vtbl struct with a generic parameter, what's the difference?
Re:Classes Considered Harmful [pdf] by recursive on Wednesday January 04, 2017 @12:34PM (#13320228)
Hm. I think you're right. It's probably my classical OOP conditioning causing me to conflate them.
Re:Classes Considered Harmful [pdf] by euyyn on Wednesday January 04, 2017 @04:23AM (#13316832)
> But virtual dispatch is trivial to add where you actually need it, a bunch of function pointers in a struct and you're good to go.

Or let the compiler do it for you? It's like saying I shouldn't use first-class closures, because they're also trivial to implement manually where I actually need them.

Re:Classes Considered Harmful [pdf] by ktRolster on Tuesday January 03, 2017 @09:54PM (#13315302)
It is a convenient extra piece of flexibility. When you want to extend code in the future, inheritance can make it easier.
Re:Classes Considered Harmful [pdf] by codr4life on Wednesday January 04, 2017 @02:39AM (#13316431)
Sorry, not buying that one. There's nothing in inheritance that makes extending code easier. You either design for extension or not, has nothing to do with OOP.
Re:Classes Considered Harmful [pdf] by ktRolster on Wednesday January 04, 2017 @11:06AM (#13319368)
Inheritance creates an extra extension point automatically. You don't need to design for it.

A good, thoughtful design is better, of course.