Hacker News new | ask | show | jobs
by qsdf38100 1404 days ago
This "bloat" of C objects you mention is only there if you use virtual functions. Same as using function pointers in a C struct. But in some cases C++ can avoid the dynamic indirection thanks to templates like in std::sort while C's qsort gets passed a function pointer, called for each comparison.

Iostream do use virtual functions but it’s not the reason of its suboptimal performance. The main reason is that some strings will be copied, allocated and freed during the construction of the whole expression while printf can do its processing with minimal dynamic allocations.

1 comments

No virtual fns means no inheritance. Also, you can blame the implementation and not the language. But real-world it is slower. Can't say by how much. Why bother?