Live data from Hacker News

Inheritance was invented as a performance hack

catern.com

111–120 of 268 posts

Re: Inheritance was invented as a performance hack

#111
The original inspiration for the idea really has nothing whatever to do with its subsequent architectural role, nor with its value as a mechanism.

As a performance optimization, inheritance demonstrated value at a time when performance improvements were at least three orders of magnitude more important than they are today.

People here like to disparage OO and inheritance, but the distaste clearly is just a reaction to Java and its unfortunate lack of any other organizational mechanism, requiring abuse of the one feature for everything.

In C++, it is sometimes directly useful, with or without a vtable, independent of "OO"; and even occasionally is exactly the right thing, explicitly as an OO tool. As one tool in the toolbox, it is simple, understandable, and causes no trouble unless badly abused. It is far from the only tool, so is not often the best choice, but probably most programs of any substance have one or two places where it is better used than not.

Re: Inheritance was invented as a performance hack

#112

I'm a little confused. Inheritance, types and all that stuff are just language concepts right? Simula may have been one of the first to implement inheritance as a means to an end, but how could they have "invented" inheritance? I'm sure the idea of inheritance was already there in language proofs. [I might be really really wrong here]

I share your confusion to a degree. To me it always seemed that the concept emerged from the work on Semantic Networks [0] by Collins and Quinlan.

What's interesting is, looking at this now that these two different aspects of what we nowadays consider to be a fairly well defined computer science concept both seem to have emerged around the same time.

Could it be C & Q were inspired by the Simula guys, or vice versa maybe Simula adopted the term because the implementation "resembled" the semantic definition. Or perhaps they independently emerged from concepts that were popular at the time!

[0] https://en.wikipedia.org/wiki/Semantic_network

Re: Inheritance was invented as a performance hack

#113
post #57
post #4

Fine. But obviously it caught on for other reasons, like code reuse and an intuitive mental model. The HN appetite for posts ragging on inheritance will never be sated.

" Please don't sneer, including at the rest of the community. " https://news.ycombinator.com/newsguidelines.html

dang, amazed at your parsing abilities at hn comment scale I checked your profile to make sure you are not a machine and read that passage you quoted which assures me you are a Human being with exceptional taste. Beautiful.

For others who may be interested, poked around and found that it is a quote from The Street of Crocodiles and Other Stories, by Bruno Schulz.

https://www.goodreads.com/book/show/1576188.The_Street_of_Cr...

Re: Inheritance was invented as a performance hack

#114
post #89

Earlier quoted context omitted.

Theory usually comes after practice. People create something that works, then theorists formalizes it into a well defined concept.

I hold the view that programming patterns were invented as solutions to technical problems. It was then later that some theoretical "usefulness" or "elegance" was attached to them. One should know the technical benefits and drawbacks of programming patterns before applying them. Just because some language or environment or majority of programmers promotes it, doesn't mean that its ok to apply it. Without knowing the…

> It was then later that some theoretical "usefulness" or "elegance" was attached

This Chicken v Egg pondering is interesting. I mean, surely the term "inheritance" was used in this instance because it already resembled something that had been established in theory?

Re: Inheritance was invented as a performance hack

#116
post #107
post #103

Earlier quoted context omitted.

> "inheriting money is a way avoid being a high performer", which happens to be true By what metric? Or do you mean "a way to avoid having to be a high performer in order to achieve good results"? Isn't the whole beef with wealth inequality that given otherwise equal luck and faculties, a person who starts with more capital will gain more capital?

The two aren’t mutually exclusive. The children of the very wealthy often (usually?) share their parents’ economic advantage, thus perpetuating the inequality that originated due to economic factors. But that doesn’t mean they’re driven or that they’ll develop the same qualities that drove their parents to be successful.

Well yeah, that's why I asked.

Re: Inheritance was invented as a performance hack

#117

In my experience, 90% of the time people use inheritance but they really only cared about composition, and their language simply does not have any convenient facility to compose types and re-export their methods. With a good type system that includes traits, you almost never need virtual dispatching, as any Rust developer may tell.

That's also been my experience. I've also seen programmers use composition and delegation solely to avoid inheritance (in a language that makes it natural), and the result is often less maintainable than a design that just uses inheritance.

Re: Inheritance was invented as a performance hack

#118
post #111

The original inspiration for the idea really has nothing whatever to do with its subsequent architectural role, nor with its value as a mechanism. As a performance optimization, inheritance demonstrated value at a time when performance improvements were at least three orders of magnitude more important than they are today. People here like to disparage OO and inheritance, but the distaste clearly is just a reaction t…

IME the problem with inheritance in C++ is that it is so easy programmers reach for it instinctively, even when another tool might be a better choice in the long term. I definitely use inheritance in my c++ code, but as I've grown (and as the language has grown) I've found myself using it less and less. Perhaps that's the way it's supposed to be.

Re: Inheritance was invented as a performance hack

#119
post #98
post #89

Earlier quoted context omitted.

I hold the view that programming patterns were invented as solutions to technical problems. It was then later that some theoretical "usefulness" or "elegance" was attached to them. One should know the technical benefits and drawbacks of programming patterns before applying them. Just because some language or environment or majority of programmers promotes it, doesn't mean that its ok to apply it. Without knowing the…

The other day I got into a heated debate with a C# developer on the merits (or lack thereof) of adding an "I" prefix to interfaces. Turns out in C# there's no syntactic difference between implementing an interface and inheritance, so it makes sense in C# to explicitly state that something is an interface but, arguably, only there.

The argument against “I” is that the user (client code) of an instance shouldn’t have too care whether the type of the reference is an interface or a class. Concerns of the implementor shouldn’t determine the naming visible to the client code.

Of course, it’s an established C# convention (and inspired by the naming convention for COM interfaces) so one better sticks with it, but I think the convention was a bad choice for the reason stated above.

Re: Inheritance was invented as a performance hack

#120

Pretty off topic comment, but I read the title as "inheriting money is a way avoid being a high performer", which happens to be true, although completely irrelevant to the actual article. ;)

I first thought it was about genes and evolution...
Post reply on HN