4 ms·
> But I'm hard pressed to imagine how a C++ style that avoids vtables like the plague could really have that much to offer over straight C. I don't follow this
by jandrewrogers 5y ago
> But I'm hard pressed to imagine how a C++ style that avoids vtables like the plague could really have that much to offer over straight C.
I don't follow this argument. In my experience, use of vtables is relatively rare in modern C++ development even when you aren't trying to avoid them, many of which are elided by the compiler anyway. Regardless, in these infrequent cases it is straightforward to code equivalent functionality without vtables, since it is syntactic type-safe sugar over the code you'd have to write in C anyway. They are like C bitfields in that every systems programmer knows how to implement the equivalent functionality manually for cases when the language feature is underspecified for the purpose.
Modern C++ without vtables is only marginally different than modern C++ with vtables, the code you'd write and the features you'd use would be nearly unchanged.
- int_19h 5y agoIn fact, most of the C++ standard library doesn't have virtual methods. It's also not a coincidence that the areas that feature them most prominently (iostreams and locales) are widely considered to be very dated designs that weren't particularly good to begin with, and didn't age well.