For decades, the industry treated memory bugs as an unavoidable tax on performance. That consensus has cracked. Security agencies now call for memory-safety roadmaps, major platforms report measurable results from new languages, and engineering leaders are being asked a pointed question: why are we still writing new code in a way that invites this class of bug?
- Memory safety flaws, such as buffer overflows and use-after-free errors, have repeatedly accounted for a large share of severe vulnerabilities in big C and C++ codebases.
- Security agencies in the United States and elsewhere now recommend memory-safe languages and published roadmaps for moving toward them.
- Large vendors report that writing new code in memory-safe languages reduces vulnerabilities faster than rewriting old code.
- Rust is the leading option for systems work, but Go, Swift, Java, C#, Kotlin and hardware and tooling mitigations all have roles.
- Incremental adoption at the boundaries, with careful interoperability and training, beats big-bang rewrites.
01The bug class that will not die
Languages like C and C++ give programmers direct control over memory: they allocate it, free it, and compute addresses by hand. That control is why they power operating systems, browsers, databases and embedded devices. It is also why a single off-by-one error can turn into an exploit. A program can read past the end of a buffer, use an object after it has been freed, or write through a dangling pointer, and the language will not stop it.
The statistics have been strikingly consistent. A Microsoft Security Response Center engineer reported in 2019 that roughly 70 percent of the vulnerabilities Microsoft assigned CVEs to each year were memory safety issues. The Chromium project reached a similar figure for its serious security bugs, and Google has reported comparable proportions for Android in earlier years. Different codebases, different decades, same pattern.
Mitigations such as address randomization, stack canaries, sanitizers, fuzzing and non-executable memory raised the cost of exploitation, and they remain valuable. But they treat symptoms. Attackers adapt, and the underlying bugs keep arriving, because humans keep writing them.
Telling every programmer to be more careful is not a security strategy. Changing the language so the mistake cannot compile is.
02Policy catches up with engineering
In 2022, the US National Security Agency published guidance encouraging organizations to move to memory-safe languages. In February 2024, the White House Office of the National Cyber Director released a report titled Back to the Building Blocks, which highlighted memory safety as a foundational improvement and urged the technology industry to act. CISA and the FBI’s Product Security Bad Practices guidance recommended that manufacturers of software for critical infrastructure publish a memory safety roadmap, with a target date of January 1, 2026. In 2025, CISA and the NSA followed with further joint guidance on memory-safe languages.
These documents carry no ban on C or C++. They set expectations. Customers, auditors and insurers read them, and vendors increasingly face questionnaires asking what share of new code is memory safe and what the plan is for legacy components. The conversation has moved from whether to how fast.
This sits alongside broader secure-by-design initiatives and rules such as the European Union’s Cyber Resilience Act. Regulators care about outcomes, and memory safety is one of the clearest levers available for reducing exploitable defects across a product line.
03What the early adopters are seeing
The most persuasive evidence comes from large codebases that changed practice. Google has reported that the share of Android vulnerabilities caused by memory safety bugs fell from roughly three-quarters in 2019 to under a fifth in recent years, a decline it attributes largely to writing new code in memory-safe languages such as Rust, Kotlin and Java, rather than rewriting existing code. The insight is that bugs concentrate in new and recently changed code, and the older a piece of code gets, the fewer vulnerabilities it tends to produce. Stop adding fresh risk, and the problem shrinks over time.
Rust has grown inside Linux, where support for the language entered the kernel in 2022 and drivers written in it have started to ship. It has been adopted in cloud infrastructure projects, network proxies, virtualization tooling, browsers and parts of Windows. Many engineers cite not only safety but the strong type system and tooling as reasons they would choose it for new work.
04Rust and the alternatives
Rust achieves memory safety without a garbage collector by enforcing ownership and borrowing rules at compile time. That gives it performance in the same class as C and C++ and makes it attractive for operating system components, embedded firmware, codecs and performance-critical services. The costs are real: a steep learning curve, longer compile times, a still-maturing ecosystem in some niches and the existence of unsafe blocks, which allow the programmer to opt out of the guarantees where necessary. The key point is that unsafe code is small, explicit and auditable, rather than the default everywhere.
Rust is not the only route. Go, Java, C#, Kotlin and Swift are memory safe and fit a large share of application and service work, where a garbage collector or reference counting is acceptable. For existing C++ codebases, there are efforts to improve safety within the language, including hardened standard library modes and proposals for safety profiles, though these are still evolving. At the hardware level, technologies such as memory tagging on modern Arm processors and capability architectures like CHERI aim to catch violations at runtime, which can protect code that is too large to migrate quickly.
| Approach | Best for | Strengths | Trade-offs |
|---|---|---|---|
| Rust | Systems, embedded, performance-critical services | Compile-time memory safety, no garbage collector | Learning curve, interop work, unsafe blocks need audit |
| Go, Java, C#, Kotlin | Services, apps, tooling | Mature ecosystems, fast onboarding, memory safe by default | Runtime overhead and less low-level control |
| Swift | Apple platforms, growing server and embedded use | Safe by default, modern syntax | Ecosystem strongest on Apple platforms |
| Hardened C++ and sanitizers | Large existing codebases | No rewrite, incremental gains | Reduces but does not eliminate the bug class |
| Hardware mitigations | Legacy code at scale | Catch violations at runtime | Needs supporting hardware and some performance cost |
05Making the transition without a rewrite
Successful migrations rarely look like a rewrite. They look like a perimeter. Teams choose components with high exposure and clear interfaces, such as file parsers, network protocol handlers, media decoders and authentication code, and replace or write them in a memory-safe language. The rest of the system continues in C or C++ and talks to the new code across a narrow foreign function interface.
That boundary requires care. Interop code is where mistakes hide, because it is exactly where one language’s guarantees end and another’s begin. Teams invest in generated bindings, thorough fuzzing of the boundary, and clear ownership rules for memory that crosses it. Continuous integration should run sanitizers on the legacy side, and security reviews should concentrate on every unsafe block.
Hiring and training are equally important. Rust skills remain scarcer than C++ skills in many markets, though many experienced systems programmers report picking up the language in a matter of months. Pairing, internal guilds and starting with small, well-bounded projects help new teams gain confidence before they take on mission-critical work.
06A roadmap leaders can actually use
Classify past vulnerabilities by root cause and identify which components handle untrusted input. Use the data to prioritize.
Decide that new components in designated areas will be written in a memory-safe language unless there is a documented reason not to.
Enable compiler hardening flags, sanitizers in CI, continuous fuzzing and, where available, hardware features such as memory tagging.
Define the interop layer, generate bindings where possible and put it under heavy test and review.
Write down goals, owners and dates. Customers and regulators increasingly ask for one, and it keeps the effort honest.
07What memory safety does not fix
It is worth being precise. Memory-safe languages remove a major class of vulnerabilities, but not all of them. Logic errors, injection flaws, authentication mistakes, insecure defaults, dependency risks and misconfiguration remain. A memory-safe program can still leak data or grant the wrong permissions. The argument for the shift is not that it ends insecurity, but that it eliminates a large, well-understood and persistently exploited category at the language level, freeing security teams to concentrate on the rest.
Is C++ being banned?
No. Government guidance recommends memory-safe languages and roadmaps, and does not prohibit existing languages. C and C++ will remain in production for decades, but expectations for new development are shifting.
Should we rewrite our whole codebase in Rust?
Usually not. Evidence from large platforms suggests focusing on new code and high-risk components delivers most of the benefit with much less risk and cost than a full rewrite.
Does unsafe Rust defeat the point?
Unsafe blocks let developers bypass checks where needed, but they are explicit, limited in scope and easier to audit than an entire codebase where every line carries the same risk.
Is Rust fast enough for performance-critical work?
Generally yes. It compiles to native code and offers performance comparable to C and C++ in most workloads, without requiring a garbage collector.
