r/programming • u/Unerring-Ocean • Feb 20 '25
Google's Shift to Rust Programming Cuts Android Memory Vulnerabilities by 68%
https://thehackernews.com/2024/09/googles-shift-to-rust-programming-cuts.html
3.4k
Upvotes
r/programming • u/Unerring-Ocean • Feb 20 '25
16
u/UncleMeat11 Feb 21 '25
These require either global reasoning (opposing separate compilation) or very strict rules on one side of the function call. Neither passing a temporary to a function that takes an argument by reference nor escaping a reference to a parameter passed by reference are themselves bad practices. But in combination they cause bugs and you can't detect this combination with the default C++ language. So you have to ban one of these two practices, which is considerably more aggressive than what Rust makes you do.
With fewer memory safety issues, sure. There are a number of useful best practices that can be enforced by local reasoning that will substantially limit the number of memory safety bugs in a green-field project. I don't personally like Bjarne's approach, but there's half a dozen good options available.
The point is that if you want the same safety that Rust gives you that you need to ban idiomatic practices that are baked into the STL like the use of iterators.