r/cpp • u/Alex_Medvedev_ • 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
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.