r/cpp • • Apr 23 '26

Devirtualization and Static Polymorphism

https://david.alvarezrosa.com/posts/devirtualization-and-static-polymorphism/
81 Upvotes

36 comments sorted by

View all comments

Show parent comment

0

u/[deleted] Apr 23 '26

[deleted] — view deleted comment

7

u/Creator13 Apr 23 '26

But the performance implications of vtables are not common knowledge for every programmer ever either. Hell, even knowing about cache locality, prefetching, or pointer indirection are pretty obscure details if you come from, say, python.

4

u/frnxt Apr 23 '26

For some reason that was never touched in any of the C++ courses I took part in, I only discovered it much later back when I was a young engineer. So that was definitely deep for back-then-me.

4

u/ts826848 Apr 23 '26

The path is “how do virtual functions work?” -> “vtables”.

Even if you assume that as a baseline the downstream consequences aren't necessarily obvious, especially if you take into account the background needed to understand why some things are faster than others on modern hardware.

Damn, that’s deep.

You might be surprised what different backgrounds cover!