2 ms·
C and C++ are similar. They're technically not subset/superset, but like, 90% of the features in C are also in C++. Idiomatic C++ programming looks very differe
by armchairhacker 3y ago
C and C++ are similar. They're technically not subset/superset, but like, 90% of the features in C are also in C++. Idiomatic C++ programming looks very different than idiomatic C programming, but most people who write C++ can write half-decent (albeit maybe not idiomatic) C; and they can learn to write idiomatic C without much of a learning curve, because the fundamentals are the same(low-level data with explicit stack/heap and memory managemnt, no guardrails, old language WATs and footguns).
- nine_k 3y agoC++ is radically different from C. It has classes (with plain constructors, copy constructors, destructors, visibility rules), exceptions, templates, operator overloading, move, RAII, stuff like constexpr, to name a few. Due to the above, stuff like `{ Foo * c = a + b; }` may have a completely different interpretation in C++ than in C. Few people would write C++ as if it were C. They would then rather write C instead. A C++ compiler happens to include a C compiler, and allows to easily mix C++ and C code. This is just a convenience; the Zig compiler also includes a C compiler and allows to easily mix in C code, but nobody would mistake Zig for C. Saying "C/C++" is like saying "car/aircraft", just because an F-150 and a Cessna 182 happen to include a piston engine and a seat behind it.
- linkdd 3y agoSpeaking of Cessna, `{ Foo * c = a + b; }` could be a valid implementation of flight simulator.