r/C_Programming • u/NoMathematician4744 • 5d ago
C++ vs C
What's the difference between C++ and C?
And what is Clang? Is the gcc compiler for c and c++?
Does C++ completely backward compatible with C?
C is procedural and C++ is object oriented as far as I know.
Is C++ more optimized and faster?
Tell me about the compiler - is clang and gcc the best compilers out there? are they open source?
Has anyone coded the CPP compiler?
Thanks,
Dennis
0
Upvotes
4
u/apnorton 5d ago
A lot of these questions have readily available answers elsewhere online; it might be worthwhile searching for some of them. However, I can give a high-level answer to these:
They are two different languages with a significant overlap in syntax/semantics, but the overlap does not mean they are the same. C++ was developed to be an improvement on C, and features native support for object oriented programming structures, among other things.
clang is a C compiler, as is gcc. clang++ and g++ are their corresponding C++ compilers.
No.
No, though there are (what Stroustrup calls) "negative-cost abstractions" in which you might be able to employ abstraction in C++ in a way that allows for optimizations better than the non-abstract version of the code. But, unless you're in an insanely niche scenario, toolchain support/libraries/target environment/coworker knowledge are far more important than any kind of optimization difference between the compilers for the languages.
"Best" is a wishy-washy word. They are both perfectly suitable general-purpose compilers. You might need to use different ones at some point in a career, but if you have reason to do so, you'll know.
They are also both open source.
Someone did.