Re:Inheritance was invented as a performance hack
by SilverRed on Thursday April 29, 2021 @10:12PM
(#26989176)
What benefit does inheritance provide over importing files containing functions? Ruby and loads of other languages let you import files and those functions work like they were part of the class itself.
[ Parent
| on HN ]
Re:Inheritance was invented as a performance hack
by rectang on Thursday April 29, 2021 @10:16PM
(#26989207)
Many benefits (e.g. attaching behavior to instances rather than modules, though there are other ways to accomplish the same goal), many drawbacks (fragility, yoyoing, etc.). C could be described as "files containing functions", and C++ was originally "C with classes", so it's not like "files with functions" is a revolutionary idea. This is all extremely well-traveled ground.
I'm happy these days using languages like Rust and Go that avoid classical inheritance, so I'm not here to argue in favor of inheritance. I'm just irritated by the pile-on.
Re:Inheritance was invented as a performance hack
by fiddlerwoaroof on Thursday April 29, 2021 @10:24PM
(#26989256)
I’d also add that live systems like Smalltalk avoid a lot of the fragility and dynamism of inheritance by the way the browsers show all the currently active extensions to the class, and all the current subclasses in a fairly compact view. It’s a lot easier to find and modify affected child classes in this way than it is with “code in files” systems.
Also, the way CLOS does inheritance avoids a lot of the drawbacks too by decoupling classes and inheritance from behavior.
Re:Inheritance was invented as a performance hack
by FpUser on Thursday April 29, 2021 @11:07PM
(#26989495)
These are those different features. Delphi / ObjectPascal for example support either.
As for what benefit - your example with Ruby can be reversed and I can ask you the same question.
Anyways large part of a programming is an art and different people have different approaches. If you do not like the concept do not use it. Just do not assume that what you think is the "right way".