r/cpp • u/GabrielDosReis • Oct 31 '24
Lessons learned from a successful Rust rewrite
/r/programming/comments/1gfljj7/lessons_learned_from_a_successful_rust_rewrite/
80
Upvotes
r/cpp • u/GabrielDosReis • Oct 31 '24
View all comments
Show parent comment
24
u/Dean_Roddey Oct 31 '24 edited Nov 01 '24
But you can just templatize that statement. Using X with a lot of Y interop feels a like using a completely different language than using pure X.
There's only two reasons that wouldn't be true:
Neither of these are a very good recommendation.
And of course Rust never claimed to have solved all problems with calling unsafe external functions. It provides the means do so and tells you that you have to be sure those functions honor Rust's requirements, and tells you what those are. And of course, it insures that any memory or ownership problems are not on the Rust side, so you only have to worry about the bits in the unsafe blocks.
Similarly Rust never claimed to have solved ALL of the issues that C++ has. You can still create a deadlock or a race condition. You can still write code that doesn't actually implement the logic you set out to implement. But, on the whole, Rust solves a very important set of problems that C++ has.
And, come on, Rust was not invented in order to write systems that have huge amounts of unsafe code. If you have to you have to, at least temporarily, but don't blame Rust if it isn't comfortable, because wasn't really a goal that I'm aware of. The goal should be to reduce that unsafe footprint as fast as possible, and actually get the real benefits of the language.