All C code can be compiled with the C++ compiler, though there’s some nuance (if you don’t mark the C code as C, it behaves slightly differently which could mean it doesn’t work).
C++ adds a bunch of language features (object-oriented programming and templates are two massive ones). This can make it easier to describe a concept in C++ than in C. But it also enables a lot of unneeded complexity (if C++ wasn’t the best fit, or if the programmers aren’t excellent) and the compiler is slower because of all the extra stuff. And the resulting binaries are much bigger. And it’s harder to port the C++ compiler to other platforms. There’s still plenty of situations where it makes more sense to use C over C++.
Good points! It’s been a while since I touched either - my current job is mainly webdeb/fullstacky crap and I haven’t touched c/cpp for years. Miss it though.
All C code can be compiled with the C++ compiler, though there’s some nuance (if you don’t mark the C code as C, it behaves slightly differently which could mean it doesn’t work).
C++ adds a bunch of language features (object-oriented programming and templates are two massive ones). This can make it easier to describe a concept in C++ than in C. But it also enables a lot of unneeded complexity (if C++ wasn’t the best fit, or if the programmers aren’t excellent) and the compiler is slower because of all the extra stuff. And the resulting binaries are much bigger. And it’s harder to port the C++ compiler to other platforms. There’s still plenty of situations where it makes more sense to use C over C++.
Good points! It’s been a while since I touched either - my current job is mainly webdeb/fullstacky crap and I haven’t touched c/cpp for years. Miss it though.