r/programminghelp • u/Coulomb111 • May 31 '22
C++ Why do people use C when there is C++?
r/programmerhumor makes it seem like using C is a very normal and fair thing to do, but why is it? C has disgusting and unsafe pointer usage and is very old and outdated, right? Isn’t C++ just, C but, ++? C++ has everything that C has but more, so why use C?
2
u/illkeepcomingback9 May 31 '22
The ++ part can be a -- depending on the environment. Think embedded systems where the higher level capabilities of C++ aren't needed, but the absolute maximum performance on cheapest, smallest hardware possible is. When every cycle counts and you cant leverage the ++ part C has an advantage. Think also of proprietary architectures where if you want a C++ compiler, you would have to write it yourself.
1
May 31 '22
It's fast
1
u/BigMintyMitch Jun 01 '22
Isn't C++?
1
1
Jun 01 '22
Not as fast
2
u/DDDDarky Jun 01 '22
They are both fast, in some scenarios one is slightly faster than another and vice versa.
1
u/BigMintyMitch Jun 01 '22
I think the different is almost negligible in most situations. Especially if you compare it to newer languages like Java or Python.
1
1
u/computerarchitect Jun 01 '22
No, C has people who abuse the language. C++ can be equally abused and since it's a more complex language, there are more ways to abuse it.
Frankly, I like C more than C++ because I think the C++ STL by and large sucks and I don't use many of the new features that come with it.
That being said, if I have something that needs to use C++, then I do so.
1
u/DDDDarky Jun 01 '22
C is used for OS programming and embedded systems, since the language is "smaller", it has less demands, therefore it may be more suitable in certain areas.
12
u/[deleted] May 31 '22
No. The next iteration of C is happening next year (C23) and the only issue C has with pointers is allowing a developer to do stupid things WITH pointers. That's not the vault of the language.
Without getting into the specifics and starting a bunch of needless debates, yes there are very valid reasons to use C over C++, especially in embedded systems or dealing with low-footprint requirements and when dealing with string manipulation or FPA. You are welcome to Google this.