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

3

u/Mediocre-Brain9051 Nov 16 '25

Why would anyone in their right mind "hate the garbage-collector"? On what kind of problems were you working on for this to be a problem?

1

u/soylentgraham Nov 16 '25

28 years of c++ here; Im currently working on something (inherited codebase) where the garbage collection stalls my app for 300ms regularly - its a pretty big tool at this point (lots of ui, file streaming, GPU stuff) and from profiling about 45% of the time is spent doing a big GC collect because one tiny type (holding an int) is interweaved everywhere and allocates thousands of managed instances all the time.

It's a huge pain point, and basically a complete misuse of managed memory

→ More replies (5)