3 ms·
I'd say, RAII and the template system are the main difference between C and C++, not the OOP features. "Zero cost abstraction" is mainly just a welcome side eff
by flohofwoe 4y ago
I'd say, RAII and the template system are the main difference between C and C++, not the OOP features. "Zero cost abstraction" is mainly just a welcome side effect of the compiler's optimization passes, and those work in C just as well as in C++ (but typical C++ code depends more heavily on compiler optimizations to clean up redundant "left-overs" from template resolution).
- Koshkin 4y ago> RAII and the template system Also function and operator overloading, often overlooked while being of critical importance.
- fckgnad 4y agoNo. Zero cost abstraction was a term used by inventor of C++. It was one of the design principles. Not a side effect. Source: https://www.stroustrup.com/ETAPS-corrected-draft.pdf https://www.stroustrup.com/ETAPS-corrected-draft.pdf Search for "Zero-overhead abstraction mechanisms". If you read it you will see Bjarnes goal was to provide the highest level of abstraction possible at "zero overhead". At the time he was creating the language, OOP was the newest and "highest" forms abstraction around... problems with it as an abstraction weren't as evident back then as they are now. But yeah, I agree that you can make an argument for RAII and templating being the main differences over OOP. But Zero cost abstractions are not a side effect at all.