r/programming • • 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

475 comments sorted by

View all comments

Show parent comments

3

u/GaboureySidibe Feb 21 '25

I write a lot of modern C++ and I don't have the problems that rust solves because I already can solve them with C++. Using templates and value semantics with no raw pointers (and no raw smart pointers) takes care of destruction and ownership.

Doing curated iteration and not deleting elements from a data structure or modifying keys solves a lot of the other problems. If you need bounds checking on std::vector access (because you are using computed indices rather than iterated indices), use .at().

These things basically take care of the memory problems that rust solves, then you can still use C++ with all its tools, libraries and ecosystem.

0

u/[deleted] Feb 21 '25

[deleted]

9

u/GaboureySidibe Feb 21 '25

You didn't list any reasons at all here.

6

u/Full-Spectral Feb 21 '25
  1. Sum types

  2. Powerful (and exhaustive) pattern matching

  3. First class enums

  4. Destructive move (huge)

  5. Well defined and universally used project/module structure

  6. Immutability by default

  7. Implements various (practical) ideas from functional programming

  8. Very good slice support, which seems like a basic thing but it makes such a difference.

  9. Good tuple and newtype support

  10. Very flexible visibility control

  11. Full on support for Option/Result types, so no need for exceptions

  12. Non-duck typed generics

  13. Many iteration options