Live data from Hacker News

Inheritance was invented as a performance hack

catern.com

11–20 of 268 posts

Re: Inheritance was invented as a performance hack

#12
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.

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.

[deleted]

Re: Inheritance was invented as a performance hack

#13
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.

Is this ragging on inheritance? I don't see much in the way of value judgements mentioned. The closest is an assertion that doing things for performance is not bad, which seems more like a way of heading off comments like yours than anything else.

It's a bit of interesting history. I don't know why it would get a "Fine. But unrelated stuff" response.

Re: Inheritance was invented as a performance hack

#14
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.

"Catching on" doesn't mean "is the right way to do things". Code reuse is in fact a prime example of a misuse of inheritance

How is it a misuse? And what are the alternatives?

To be clear, I do agree with your assertion, however I'm having a hard time actually putting "how/why" into words.

Re: Inheritance was invented as a performance hack

#15

I spent way too long trying to figure out how giving your kids your lifetime's earnings would be a performance hack beyond, you know, giving them a head start, before realizing what the headline was talking about.

I figured cause it was on HN that there was no way that was the article

Re: Inheritance was invented as a performance hack

#16
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.

"Catching on" doesn't mean "is the right way to do things". Code reuse is in fact a prime example of a misuse of inheritance

Correctly using a language feature often means using it for more than one reason. Extending superclass code can be well advised in case it also makes sense semantically. Now, I have seen a "mixin" class that just served to provide one relatively independent method, and I turned it into a free function. Much better. In other cases, an extended class works on the whole state of the object. In that case it usually makes sense.

Re: Inheritance was invented as a performance hack

#17
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.

"Catching on" doesn't mean "is the right way to do things". Code reuse is in fact a prime example of a misuse of inheritance

Why is code reuse your prime example for bad inheritance? What should people do instead?

Re: Inheritance was invented as a performance hack

#18
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.

Is this ragging on inheritance? I don't see much in the way of value judgements mentioned. The closest is an assertion that doing things for performance is not bad, which seems more like a way of heading off comments like yours than anything else. It's a bit of interesting history. I don't know why it would get a "Fine. But unrelated stuff" response.

I suspect that many will read the title as derogatory, even if the post is not a firebreather. Also, from the conclusion:

> Personally, for code reuse and extensibility, I prefer composition and modules.

Re: Inheritance was invented as a performance hack

#19
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]

Re: Inheritance was invented as a performance hack

#20
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.

"Catching on" doesn't mean "is the right way to do things". Code reuse is in fact a prime example of a misuse of inheritance

> Code reuse is in fact a prime example of a misuse of inheritance

Does that depend on how inheritance works in a particular language? For example, in Python it’s widely believed that inheritance is simply “a tool for code reuse” [0].

[0] https://youtu.be/EiOglTERPEo?t=190

Post reply on HN