r/cpp • • Sep 04 '23

Considering C++ over Rust.

Similar thread on r/rust

To give a brief intro, I have worked with both Rust and C++. Rust mainly for web servers plus CLI tools, and C++ for game development (Unreal Engine) and writing UE plugins.

Recently one of my friend, who's a Javascript dev said to me in a conversation, "why are you using C++, it's bad and Rust fixes all the issues C++ has". That's one of the major slogan Rust community has been using. And to be fair, that's none of the reasons I started using Rust for - it was the ease of using a standard package manager, cargo. One more reason being the creator of Node saying "I won't ever start a new C++ project again in my life" on his talk about Deno (the Node.js successor written in Rust)

On the other hand, I've been working with C++ for years, heavily with Unreal Engine, and I have never in my life faced an issue that usually the rust community lists. There are smart pointers, and I feel like modern C++ fixes a lot of issues that are being addressed as weak points of C++. I think, it mainly depends on what kind of programmer you are, and how experienced you are in it.

I wanted to ask the people at r/cpp, what is your take on this? Did you try Rust? What's the reason you still prefer using C++ over rust. Or did you eventually move away from C++?

Kind of curious.

355 Upvotes

434 comments sorted by

View all comments

0

u/Fiskepudding Sep 05 '23

3

u/DiscoVoadordeVenus Sep 06 '23

C++ is not too bad in terms of safety. The biggest problem is that people treat C++ like if it was C. C++ is much more safe than C, very much more.

There are many safety related problems with all languages. I saw some statistics in cpponsea conference lecture some days ago.

https://youtu.be/BaUv9sgLCPc?si=bwhhrReWTpWYRn4l

1

u/KingStannis2020 Sep 06 '23

Here's the thing, and I'm not calling you out specifically but rather the community in general - if you go around promoting how much better C++ is than C, you can hardly get upset when Rust users promote ways in which Rust is better than C++

And you can't laugh at the C devs saying "I don't have the issues you speak of because I write code properly" while dismissing Rust devs with the same argument.

3

u/DiscoVoadordeVenus Sep 06 '23

The bigger problem with Rust is that it doesn't have good interop with C++. There's so much things using C++ in the world, e.g:

- The game industry has no need to change.

- All scientific works using C++ have no need to change.

Only where people really need to try to reinforce their code safety for security reason may think of using Rust.

Lots of library's and API like Cuda, Directx, OpenGL, Vulkan, OpenCL, OpenCV etc etc etc.

I think Carbon language may have a high chance to be a C++ successor because its been made to have good C++ interoperability and memory safe.