simeonz wrote:
When you manipulate different object types uniformly, you have polymorhism, C++ or not. Behavior variation requires data that specifies it, and the single pointer in C++ is pretty minimal cost. Error handling with branches, even if properly predicted by the CPU, should still be marginally slower in the normal path. It makes for a horribly looking coding style as well. Exceptions are slower in the failure path only, and it is rarely taken. Together with RAII, they make error handling much more capsulated affair. Templates offers type safe alternative to macros, and although it is true that sometimes compilers fail to chew them info efficient code, that depends on how extensively they are used and how deeply they are nested, as well as the compiler. Genericity is a very convenient library feature.
On the other hand, it is true that templates come at the cost of making the project header centric, and dependent on inclusion order. Also, polymorphism with some syntax features make the semantics so flexible, that the code looses its self-contained meaning and can become unpredictable. Exceptions introduce hidden control flow, which must be tracked at all times, and good knowledge of RAII becomes necessity. The biggest caveat in my opinion however is that people tend to produce high-level abstractions that eventually become costly. But this is not due to C++ in itself, but due to the comfort with which such abstractions are produced in OOP style. It is abstraction that is expensive, not C++.
Branch prediction works in 95% of the cases very well, I really dislike the way exceptions look like and work though.
Anyways you are are completely right, its not the fault of OOP languages but the people using them, I think I should have made that a bit more clear in my previous post.
The problem is the easier languages get for people, the more such people exist which leads to alot of bad written and slow software these days.