Earlier quoted context omitted.
Inheritance is a natural phenomenon. If all my money were stolen when I die (let's say, 100% inheritance tax), I wouldn't have much incentive to grow my business more once my business makes more money than I can possibly spend in a lifetime. Sure, some people may still do it because they love working or because they love providing for their society. The main reason I want to accumulate money, is so I can offer them a…
Your business doesn't operate in a vacuum. It is licensed and supported by society. The same society that benefits from inheritance redistribution.
Inheritance was invented as a performance hack
161–170 of 268 posts
Re: Inheritance was invented as a performance hack
#162Earlier quoted context omitted.
> How could std::is_same be implemented? You would perform manual static context-sensitive text expansion, just like the C++ template expander does. In this case, you end up just manually expanding it all the way out to a true or false by hand. I'm just saying that the C++ template expander only performs static context-sensitive text replacements, ending in valid template-free C++ code. The template engine doesn't in…
C++ templates cannot be implemented purely by text replacement as most of it is type driven. It is true that you can do anything that templates do by hand, but that's true for any language construct (at the limit you could write asm).
The static types (and constant values in some cases) are the context. That's the "context-sensitive" part of "context-sensitive expansion".
> It is true that you can do anything that templates do by hand, but that's true for any language construct (at the limit you could write asm).
Yes. That's my point. I was replying to someone saying that they could remove a layer of indirection from a linked list by writing a custom data structure that had the next and previous references, and I was pointing out that they're essentially running C++ template expansion by hand. There's nothing surprising there.
Re: Inheritance was invented as a performance hack
#163Earlier quoted context omitted.
Yes, I mean java.util.LinkedList. Obviously, one can do manual writing of Java (or even use m4 macros or hijack the C preprocessor... the preprocessor doesn't know anything about C beyond tokenization) for anything C++ templates can do. It's just tedious and potentially error-prone. Here's hoping Java eventually gets reified generics.
Obviously you can do public class Node { Node prev, next; //stuff comes here .... } Then extend and have the overall code that deals with modifying the datastructure, but it's overall ugly. Personally I have written enough datastructures where linking nodes is useful. For example: red/black tree + insert order 'next' makes for a decent implementation of a moving median. Yet, that's not what almost any developer would…
Re: Inheritance was invented as a performance hack
#164Earlier quoted context omitted.
Your business doesn't operate in a vacuum. It is licensed and supported by society. The same society that benefits from inheritance redistribution.
By that logic, why let the business owner make any money at all? It's really society's business after all.
Re: Inheritance was invented as a performance hack
#165Earlier quoted context omitted.
Your business doesn't operate in a vacuum. It is licensed and supported by society. The same society that benefits from inheritance redistribution.
By that logic, why let the business owner make any money at all? It's really society's business after all.
Re: Inheritance was invented as a performance hack
#166Earlier quoted context omitted.
Obviously you can do public class Node { Node prev, next; //stuff comes here .... } Then extend and have the overall code that deals with modifying the datastructure, but it's overall ugly. Personally I have written enough datastructures where linking nodes is useful. For example: red/black tree + insert order 'next' makes for a decent implementation of a moving median. Yet, that's not what almost any developer would…
But isn't that just what you were suggesting in the GP post in order to get rid of a layer of indirection?
Re: Inheritance was invented as a performance hack
#167Pretty 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. ;)
Re: Inheritance was invented as a performance hack
#168Earlier quoted context omitted.
Interfaces with default implementations are better than classes for a number of reasons, including the diamond problem, and that as systems grow large they almost never fit cleanly into an inheritance tree. Fat pointers with two words, one for an interface vtable and one for the object, work really well.
> Interfaces with default implementations are better than classes for a number of reasons it's literally the same thing in practice > including the diamond problem, the diamond problem has only ever been a "problem" in OOP textbooks, in years and years of working on OO system I have never saw it be a problem in practice
https://www.usenix.org/legacy/publications/compsystems/1989/...
The plan seems so complex that it makes complete sense to me why languages would avoid multiple class inheritance (where each class is afforded direct access to member variables).
In contrast:
• With single inheritance, you don't have to resolve different member variable layouts because there is only one.
• With interface inheritance (with or without default methods), interface methods don't get to access struct members directly and know nothing about object memory layout.
Re: Inheritance was invented as a performance hack
#169Earlier quoted context omitted.
My roots are in OO but for the life of me I could never figure out why people found inheritance intuitive beyond some automatic delegation (like Go’s struct embedding). I certainly don’t miss the guesswork of trying to figure out which class’s virtual method is being executed out of the dozen in the hierarchy (especially when one virtual method is calling other virtual methods).
Because some people understand "is a" better than "has a".
Re: Inheritance was invented as a performance hack
#170Earlier quoted context omitted.
Maybe he meant something similar to Go interfaces, but they are abstract and coupled loosely with implementations after the fact. That or abstract class/pure interface. There's no need for default implementations introducing assumptions in code.
"Interfaces with default implementations" are a thing in Java and in some other languages, but most people don't know about them: https://docs.oracle.com/javase/tutorial/java/IandI/defaultme...