News for hackers. Stuff that matters.
Re:Inheritance was invented as a performance hack by matkoniecz on Thursday May 08, 2025 @04:25AM (#43924223)
> Say you have two structs. The structs contain redundant properties. HOW do you define one struct in terms of the other? There's no simpler way then inheritance.

why inheritance would make it easier?

Re:Inheritance was invented as a performance hack by ninetyninenine on Thursday May 08, 2025 @02:03PM (#43929254)
I have: A = {a, b, c, d, e}

I want to write: B = {a, b, c, d, e, f, g}

But I don't want to write duplicate code

So I write:

   B = B(A) = {A, e, f, g} 
aka I use inheritance.

Are there easier ways? No. Inheritance is the most fundamental way of doing this. Composition is just a work around as it results in arbitrary nesting. But ultimately it's the same thing too.