5 ms·
"The author uses C and C++ interchangeably, but these are two distinct languages" Sure they are. C/C++ are often cobbled together in a sense that they are both
by kbart 10y ago
"The author uses C and C++ interchangeably, but these are two distinct languages"
Sure they are. C/C++ are often cobbled together in a sense that they are both low level, non-memory safe and non-type safe languages, as opposite to high level, safe, memory managed (aka "modern") languages.
- johannes1234321 10y agoC++ is a type-safe language (unless you use C-features like void*, which you shouldn't in C++) it is high-level (thanks to templates likely more high-level than many others). If you think of C++ as "C with classes" then you can mix them, but C++ evolved quite a lot with C++11 and following standards and implementations.
- kbart 10y agoI somewhat agree with that, but unlike in most other modern languages, type-safety is not enforced, thus you can't call it a pure type-safe language even though you can write programs in type-safe way. Same with low/high level -- you can use C++ as low level (C with classes) or as high level according to modern C++ standards (C++11, C++14) and best practices. There's no strict classification, I just wanted to highlight C++ similarities with C.
- johannes1234321 10y agoThe C++-fan would say you have the tools to ignore type safety, so you can opt-out. But that's of course a matter of perspective. A good, modern, tutorial should only teach type-safe tools to beginners.
- KKKKkkkk1 10y agoSpeaking of type safety, has modern C++ solved the object slicing problem yet?
- TheCoelacanth 10y agoYes, they're called references.
- dbaupp 10y agoThere's too much undefined behaviour for even modern C++ to be considered type safe: a dangling reference or invalidated iterator allows you to break it easily, accidentally. (Even "opt-out type safety" is a stretch, opt-in-with-extra-tooling-and-tests seems more appropriate.)
- Manishearth 10y agoIn the context of the first paragraph in this post, they are not. The stuff he talks of in that paragraph applies to C, not C++.