4 ms·
>Over the past decades, in addition to large Java and Go memory-safe codebases, Google has developed and accumulated hundreds of millions of lines of C++ code t
by mrkramer 2y ago
>Over the past decades, in addition to large Java and Go memory-safe codebases, Google has developed and accumulated hundreds of millions of lines of C++ code that is in active use and under active, ongoing development. This very large existing codebase results in significant challenges for a transition to memory safety:
We see no realistic path for an evolution of C++ into a language with rigorous memory safety guarantees that include temporal safety.
A large-scale rewrite of all existing C++ code into a different, memory-safe language appears very difficult and will likely remain impractical[0].
[0] https://security.googleblog.com/2024/03/secure-by-design-googles-perspective-on.html#:~:text=Over%20the%20past,likely%20remain%20impractical https://security.googleblog.com/2024/03/secure-by-design-goo....
Long story short; they are stuck with millions of C++ LOC and they can't transition to Rust completely because of the enormous complexity of various gigantic codebases e.g. Android, Chrome or whatever they want to move to memory-safe language/s.
They said they will try to write as much new native code in Rust as they can plus they will interop from C++ to Rust in order to reduce memory-safety bugs.
- niutech 2y agoCan't they use a transpiler from C++ to Rust? E.g. https://llvm.org/devmtg/2023-05/slides/Posters/02-Preto-AutomaticTranslationCPlusPlus-Rust.pdf https://llvm.org/devmtg/2023-05/slides/Posters/02-Preto-Auto...
- swiftcoder 2y agoEventually, maybe. In the short term, the transpilers mostly translate from other languages into unsafe Rust - which is a helpful tool during porting, but there is still a mountain of work to refactor unsafe idioms into safe before you really reap the benefits.
- niutech 2y agoThe presentation I linked talks about transpiling C++ to safe Rust.
- swiftcoder 2y agoYes, there are a few such efforts ( such as https://arxiv.org/pdf/2401.08264 https://arxiv.org/pdf/2401.08264 ). My understanding is that all are still somewhat experimental.