3 ms·
C++ not only fails to hide the above-mentioned C pitfalls but adds entire classes of pitfalls of its own. Just a few examples: * undecidable grammar: http://yo
by AlexandrB 12y ago
C++ not only fails to hide the above-mentioned C pitfalls but adds entire classes of pitfalls of its own. Just a few examples:
* undecidable grammar: http://yosefk.com/c++fqa/defective.html#defect-2 http://yosefk.com/c++fqa/defective.html#defect-2
* const inside containers: http://yosefk.com/c++fqa/const.html#fqa-18.1 http://yosefk.com/c++fqa/const.html#fqa-18.1
* template error messages
http://yosefk.com/c++fqa/templates.html#fqa-35.17 http://yosefk.com/c++fqa/templates.html#fqa-35.17
C is often nicer than C++ because it's simpler: it only has the C pitfalls not the combination of C & C++ pitfalls that plague C++.
- vitaut 12y agoThese are trivial issues compared to major safety and usability flaws inherited from C that I mentioned. BTW the C grammar is not context-free either. The compilation speed is mostly due to header system which is again a C heritage, not because the C++ grammar is undecidable. And template error messages are much better now in modern compilers such as Clang. As for the const, its semantics is the same as in C.
- the_why_of_y 11y agoThe super-slow compilation speed is mostly because C++ encourages massive all-inline template libraries like the standard C++ library and boost, which need to be parsed and have the used templates instantiated for every compilation unit. Here's idiomatic hello world, with <iostream> vs. <stdio.h> > g++ -E hello.cc | wc -l 17906 > gcc -E hello.c | wc -l 842