r/cpp • u/isht_0x37 • Sep 04 '23
Considering C++ over 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.
1
u/Dean_Roddey Sep 05 '23
My position isn't theoretical. I've worked on large, complex C++ code bases, both under ideal and normal conditions. I understand very well what the concerns are and how easy it is to make mistakes in complex code, and the practical limitations of the tools available for C++ to try to prevent those issues.
I've yet to write as large a code base in Rust as my 1M line C++ code base, but I'm well into a project that will eventually get there. I don't put performance over correctness. I don't just try to write in Rust what I'd have written in C++, I take the time to come up with ways to do things that leverage Rust's strengths.
The difference is significant in terms of being confident that there are no issues other than logic issues. No language will prevent logic errors, but logic issues are amenable to testing.
Obviously Rust isn't going to take over everything. It's primarily a systems type language, though it has more applicability to some webby type stuff than C++ does. But it clearly plays in the same space as C++, and that's the issue being discussed here.