4 ms·
Details may matter for performance (though in my experience people tend to gravitate towards such things while ignoring asymptotic improvements that can be far
by betterunix 13y ago
Details may matter for performance (though in my experience people tend to gravitate towards such things while ignoring asymptotic improvements that can be far more dramatic), but C++ is annoying even if that is something you are trying to do. C++ has a tendency to insert "surprises" into compiled code -- lots of implicit function calls, copies, etc.
I saw this sort of thing first-hand when I TA'd a data structures course taught in C++, when a student came to me asking for help with some very bizarre behavior: a member function was being called for an object that had never been allocated. The problem was that the student had forgotten to write a return statement (why is that even allowed? compilers can obvious detect this, since using -Wall picked it up), and a virtual destructor call had been inserted, but the vtbl for some other object was sitting there and so some other member function for an unrelated class was called.
So while you are sitting there trying to figure out if your class members are aligned optimally, your C++ compiler is inserting function calls and not letting you know about it. If it were just a few implicit calls or copies, it would not be a big deal, but C++ is a huge, complicated language with lots of such things.
Basically, almost everything you mentioned is a low-level concern for which high-level constructs are just a distraction. The point of high-level programming is to direct programmer effort away from such things (hence the implicit function calls and copies, etc.). If you want to program at a low level, fine -- but my point was that in C++, low-level and high-level programming are too tightly coupled.
Finally, it is worth pointing out that this:
"copying to enable concurrency are all real things."
Is not something C++ has any kind of advantage in. I do it in Lisp all the time. You see it in functional programming languages all the time.
- dman 13y agoThe C++ philosophy is to only pay for costs of things that you actually use. Making every check in -Wall an error by default would make every one pay the costs of those extra checks at compile time.