4 ms·
You've got it backwards. For the same amount of polymorphism in the design of a program C++ is likely to be faster because a C++ compiler can often devirtualize
by jeffbee 6y ago
You've got it backwards. For the same amount of polymorphism in the design of a program C++ is likely to be faster because a C++ compiler can often devirtualize calls but a C compiler faced with a home-grown vtable (the struct of function pointers that every large C program eventually uses) will never be able to do so.
- vitus 6y agoWhy bother to write the vtable in the first place? My experience is that C++ that's written for performance will often prefer the use of templates over inheritance since the cost is then paid upfront by the compiler. What's stopping a C programmer from hand-coding template instantiations (via macro or otherwise)?
- jeffbee 6y agoSure you are welcome to reimplement C++ in C macros. When your time is worthless anything is possible.
- Skunkleton 6y ago> When your time is worthless anything is possible. I kinda want this on a mug or something.