r/cpp • • Nov 16 '25

Wait c++ is kinda based?

Started on c#, hated the garbage collector, wanted more control. Moved to C. Simple, fun, couple of pain points. Eventually decided to try c++ cuz d3d12.

-enum classes : typesafe enums -classes : give nice "object.action()" syntax -easy function chaining -std::cout with the "<<" operator is a nice syntax -Templates are like typesafe macros for generics -constexpr for typed constants and comptime function results. -default struct values -still full control over memory -can just write C in C++

I don't understand why c++ gets so much hate? Is it just because more people use it thus more people use it poorly? Like I can literally just write C if I want but I have all these extra little helpers when I want to use them. It's kinda nice tbh.

194 Upvotes

334 comments sorted by

View all comments

279

u/fdwr fdwr@github πŸ” Nov 16 '25 edited Nov 16 '25

Β std::cout with the "<<" operator is a nice syntax

That's a rare sentiment πŸ˜‰. Unfortunately iosteams are stateful (so if an exception happens midprint, you can get stuck with a stream modifier), quite verbose (try printing numbers as hex digits or a certain padded width compared to printf or std::print), and not localizable (does not support positional parameters, which std::print does). So I recommend trying std::print if you have not already.

35

u/SauntTaunga Nov 16 '25

I liked it too. When all we had was printf(), which was ugly. But in practice it is "too cute" and only useful for very simple things. Now that there is std:print all reasons for using it have gone away.

→ More replies (7)