Remix.run Logo
landdate 4 days ago

I don't understand the hate towards C++. Many of the aspects criticized for are non-issues in modern C++. I am not to knowledgable about Rust, but what reason is there to use Rust? Memory safety isn't much of a problem in C++ anymore with smart pointers, std::move. Implicit typing exists in C++ with std::auto. Functional programming with lambda, std::functional, std::map, etc. C++ does everything I have wanted it to do, has a huge ecosystem of libraries, and great tools.

lII1lIlI11ll 4 days ago | parent | next [-]

> Memory safety isn't much of a problem in C++ anymore with smart pointers, std::move.

Of course it is! You can still access an object after std::moving it somewhere, return references to local stack variables from functions, double-delete (or zero!), use uninitiated variables and do bunch of other things that rightfully caused notoriety C++ has got. And am saying it as someone who writes C++ every workday, unfortunately.

throwaway18373 4 days ago | parent [-]

You "write C++ every workday" and don't even know that moved-from objects are guaranteed to be valid?

> return references to local stack variables from functions

> use uninitiated variables

Any properly configured compiler will catch and warn about those errors.

> double-delete (or zero!)

Not a real issue if you're using smart pointers.

Sure, you can program with no compiler warnings and no smart pointers—but nothing is stopping you from wrapping your entire Rust program in "unsafe" and doing all those things there as well. Programming languages can only do so much to save people from their own incompetence.

lII1lIlI11ll 3 days ago | parent [-]

> You "write C++ every workday" and don't even know that moved-from objects are guaranteed to be valid?

I'm getting strong Dunning–Kruger vibes from your reply. Yes, moved-from objects are in valid but often unspecified state even in STL, not to mention custom code in most C++ projects I had experience with [0][1].

> Any properly configured compiler will catch and warn about those errors.

No true Scotsman compilers...

> Not a real issue if you're using smart pointers. Sure, you can program with no compiler warnings and no smart pointers...

Yeah, the good-old tried-and-true "just always manage your memory correctly and avoid having bugs" way of writing C++ software that have been working out so well.

[0] https://wiki.sei.cmu.edu/confluence/display/cplusplus/EXP63-...

[1] https://stackoverflow.com/a/17735913

thegrim33 4 days ago | parent | prev | next [-]

This'll be an "out there" comment but after coming to the conclusion long ago that governments have infrastructure built to manipulate online communities with mass propaganda, usually to impart typical political/social messaging, and then realizing that a few years ago the NSA put out an official statement about wanting people to not use C++, I finally put two and two together and realized that, being a government entity, they could have easily just tacked on an "anti-C++" campaign to the list of active propaganda farm campaigns, and viola, anti-C++ comments start appearing on forums everywhere.

saidinesh5 4 days ago | parent | prev [-]

The issue with modern c++ is ecosystem. It is still full of legacy c++ libraries. Even though people have mostly settled on cmake, it's still common to run into friction when integrating third-party libraries. Nothing as streamlined as cargo. Vcpkg, hunter, conan, vendoring in libraries etc...

Don't get me wrong. Number of C++ libraries is far bigger than number of rust libraries. But number of modern c++ libraries is still not that high i feel. So once you have integrated legacy code into your project, there's a lot of scope for newbies to create memory leaks/double free/etc ...

1718627440 3 days ago | parent [-]

That's why I only use POSIX make and shell scripts.