Why is the US government telling programmers to move away from C?
About 70% of serious security bugs in some huge codebases come from memory-safety mistakes, and agencies like CISA and the NSA now say so in writing.
▶ Start the storyThe US government's concern is not really about C itself. It is about a kind of bug that C makes easy and that causes a huge share of security holes. Memory safety is the state of being protected from software bugs and vulnerabilities in memory access, such as and . Java is memory-safe because its runtime checks array bounds and pointer dereferences. C, C++ and Fortran allow arbitrary with no , which makes them memory-unsafe.
A buffer overflow is a bug in which a program writes data beyond the end of a buffer's allocated memory, overwriting whatever lies next to it. The earliest documented hostile use of one was in 1988, as one of several exploits of the Morris worm. And the problem is not rare: in 2019 a Microsoft security engineer reported that 70% of all security vulnerabilities were caused by memory safety issues, and in 2020 a Google team found that 70% of severe security bugs in Chromium had the same cause.
70%
So CISA, the US cybersecurity agency, and the FBI listed it among "bad practices". They call developing new critical-infrastructure product lines in a memory-unsafe language such as C or C++ dangerous when readily available memory-safe languages could be used. For existing products, they say having no published memory safety roadmap is dangerous. But read closely: the guidance is non-binding and imposes no requirement, and the authors acknowledge that migrating takes significant time and resources. CISA and the NSA also published a joint guide on how to adopt memory safe languages.
Rust is one alternative that does not rely on garbage collection. It enforces memory safety without a conventional garbage collector, using a that tracks the lifetime of references at compile time. Its creator, Graydon Hoare, reportedly started it out of frustration with an apartment elevator whose software had crashed.
Quiz me
0/3
Recap
C and C++ trust the programmer to stay inside memory's lines, while memory safe languages like Java and Rust enforce the lines.
💡 A trick to remember it · Unsafe languages hand you the keys to the whole library; safe ones only let you into your own aisle.
Surprising fact · The US guidance is non-binding, and it asks for roadmaps for old software, not an overnight ban on C.
Connects to
- 🚀 How did a number too big for its box blow up a rocket?
- 🧹 Who cleans up a program's memory?
- 💔 How did one bug put much of the internet at risk, from Heartbleed to Log4Shell?
- 🪱 How did one student's experiment slow down the early internet?
- 🔓 Why did an NBA team hand over every employee's tax forms to a scammer?
Sources (5)
No source, no claim. Every fact in this lesson (15 claims) cites at least one of these.