3 ms·
At least in the case of C#, composition tends to be done via interfaces, which has more indirection than if they were to use an abstract class. This has been s
by whaleofatw2022 3y ago
At least in the case of C#, composition tends to be done via interfaces, which has more indirection than if they were to use an abstract class.
This has been somewhat mitigated in newer versions of runtime.
Not sure what it's like in JVM world, I know they had a better dervirt for a while.
- pjmlp 3y agoYeah, but that is a decade later, and also ignores the JIT optimizations like devirtualization, or just like C++ templates, using generics for composition.
- whaleofatw2022 3y ago> JIT optimizations like devirtualization JIT devirt can be nitpicky, PGO has improved the situation greatly but until around 6.0 or 7.0 devirt was easy to 'break' in a lot of common scenarios. Heck, tying into the generic composition bit, ironically static generics still have issues right around devirts. Go figure.