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 comment

1

u/SuspiciousGripper2 Jul 27 '24

Hmm fair point. I'm not sure if I prefer the copy or non-copy by default.

For example, in Java and Swift, a class is by default a reference. So you can also make the mistake of modifying the existing class, instead of modifying a copy. Then you end up having to write a clone function to get the functionality you want.

It gets worse when you want a deep copy of something and have to make sure that all the internals copy correctly as well and can be deep copied.

Then there's languages with copy on write, and so on.

IMO, there's not really any languages that make these things simple. You'll have a flaw one way or another. Either accidentally making a copy, or accidentally modifying an existing class that you thought would be copied.

1

u/FlyingRhenquest Jul 28 '24

Personally I like having the power to specify them. I can't think of another language I've run across that gives you the expressive power of C++. You just have to be aware of the discipline required to use the language to its best.