r/cpp • • Jul 25 '24

Why use C over C++

Why there are so many people using the C language instead of C++?, I mean C++ has more Cool features and the Compiler also supports many CPUs. So why People still using C?

Edit: Thanks for all the usefull comments :D

235 Upvotes

444 comments sorted by

View all comments

Show parent comments

1

u/Alex_Medvedev_ Jul 25 '24

Hey, I just tested Hello World in both languages using Compiler Explorer (https://godbolt.org/).

The assembly is a bit different but very similar, Hard to say which is better

1

u/lestofante Jul 25 '24

as expected for the same identical code;
I expect those differences would come up only for extremely specific code where the rule of C and C++ slighty differ (your use of volatile for example, as volatile has differnt meaning in C and C++).

oh btw, try optimize for size (-Os), you will see both generate pretty much the same code (again only the label differ) but exremely different thant he -O2.

1

u/_Noreturn Jul 26 '24

the link does not work.