3 ms·
I think what you are both trying to say is that C++ was designed to ensure you "only pay for what you use"? Remarkably successful at that, really. Kinda falls
by shawn-butler 14y ago
I think what you are both trying to say is that C++ was designed to ensure you "only pay for what you use"? Remarkably successful at that, really.
Kinda falls apart in some cases. For example the standard says with respect to inline functions that:
An inline function with external linkage shall have the same address in all translation units.
So I guess for the purpose of not having to worry about comparing the values of a function pointer to an inline function or worry about assignment semantics? Actually I have never really understood the point of this part of the spec.
Anyway, the cost of this is not negligible, since the linker has to maintain state for those cases where inline replacement is not an option[0]. As a result, even if you don't use this feature of the language, you pay for it with increased link time and object file sizes. But this is a pretty arcane corner case to pick on.
[0]: http://gcc.gnu.org/onlinedocs/gcc/Vague-Linkage.html http://gcc.gnu.org/onlinedocs/gcc/Vague-Linkage.html
- zanny 14y agoThere are dozens of them though, like name mangling bloating code size even if you forego namespaces. Not saying the compiler doesn't have some inherent inefficiencies, but it still is operating at the same level as C.