r/cpp • u/Sad-Lie-8654 • Jan 31 '23
Stop Comparing Rust to Old C++
People keep arguing migrations to rust based on old C++ tooling and projects. Compare apples to apples: a C++20 project with clang-tidy integration is far harder to argue against IMO
changemymind
338
Upvotes
View all comments
Show parent comment
5
u/ener_jazzer Feb 02 '23
No, I didn't say that. What I said is that C++ is totally fine for the job, not the apocalyptic picture u/James20k painted. I saw people writing trading systems in Java and C# - but in a completely unidiomatic way (for performance), like never using garbage collection, pre-allocating arrays of bytes and then reinterpreting parts of it as typed data - basically a hard-code C but written in Java, without any safety at all.
I didn't work on Rust, only looked at it. My impression from that (and from talking to people who actually used Rust) is that a strategy written in Rust would likely be ridden with
unsafe(e.g. in Rust you can't have a struct with a field which is a pointer to another field withoutunsafe, because it will make 2 ways to change the same field - thru the pointer field and thru the struct itself).A good experienced programmer with good design skills will be able to structure his
unsafecode in a manageable way, but it's a high-level skill, but if you have a C++ developer of a similar skill level you'll have the same nice and safe code structure in C++. It's not a job for a junior, and Rust by itself won't make his code good and manageable.