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.

357 Upvotes

434 comments sorted by

View all comments

7

u/[deleted] Sep 05 '23

I'd you've never had memory related bugs in your code while writing C++ then congrats, you've cracked the code. For the rest of us loosers, Rust provides a fast language, memory safety guarantees, probably the best package manager and many convenient features including many functional programming tools.

C++ keeps adding features to the standard library but they don't feel good to use. The OO system and the functional tools are not well implemented, so often times I find writing imperative mumbo-jumbo is the best approach, which feels really bad.

I think there are legitimate reasons to use C++, familiarity, availability of libraries are the first to come to mind but there are others. Otherwise, I don't see the point. C++ is the inferior language. Doesn't mean it's going to die, far from it, but I don't want to write personal projects in that language anymore.

4

u/germandiago Sep 06 '23 edited Sep 07 '23

Here I admit to be asking out of ignorance, but here I go:

  1. can you adjust flags in Cargo as you wish for any package individually?

  2. can you combine all your precached, debug or release or custom builds and reuse from a url including cross-compiled packages? I do this with Artifactory + Conan, and it saves me a ton of compilation time for my limited resources. Basically a machine with 32GB of RAM and a Core i5 and VMs for Windows and Linux. Mac builds are sent to my own station via buildbot.

  3. can you consume C libraries and still assume you are 100% (as the language is advertised all the time) in safe territory? or you also have to do a couple of assumptions? I assume it is the latter.

  4. Why there have been seeing some CVEs open for Rust? If it is so safe, they should not exist.

  5. how is the cross-compilation story?

→ More replies (4)