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.

195 Upvotes

334 comments sorted by

View all comments

Show parent comment

2

u/wyrn Nov 16 '25

A type that implements IDisposable should be used in a using clause,

Except when it shouldn't (e.g. HttpClient). Either way I still consider a using clause a form of manual disposal. It's a lot like defer in the neo-C family of languages.

Why can't you have ghost references in C++? I have seen quite a fair share of them to be honest. There is no scope for heap allocated objects that ensures their destruction.

To me that falls under "it breaks if I do the silly thing!" Well, don't do the silly thing! There's no reason to manage memory manually anymore. At the end of the day, I find myself thinking about leaks far more often when programming in C# than when programming in C++.