C Safety Debate

Cluster discusses the safety and security of C programming language, focusing on memory vulnerabilities, CVEs, ongoing bugs, and debates over whether C is suitable for modern software or should be replaced by safer alternatives like Rust.

➡️ Stable 0.5x Programming Languages
6,441
Comments
20
Years Active
5
Top Authors
#4091
Topic ID

Activity Over Time

2007
1
2008
18
2009
45
2010
39
2011
73
2012
90
2013
194
2014
383
2015
415
2016
627
2017
577
2018
369
2019
369
2020
403
2021
639
2022
610
2023
520
2024
488
2025
545
2026
36

Keywords

e.g UB SQL CompSci IMO ARM COBOL HW ANSI suckless.org code languages security safe language unsafe safety write memory bugs

Sample Comments

quotemstr Nov 13, 2022 View on HN

It's not possible for humans to write correct and secure C code on an ongoing and consistent basis. Even when people pay careful attention, problems arise: consider the various 0days in sudo. C isn't simple: it's simplistic: its apparent simplicity comes from shifting the burden of safety from compilers to humans. Consequently, we spend trillions of dollars on dealing with the consequences of security vulnerabilities, most of which wouldn't exist if programmers used me

sgt Feb 19, 2022 View on HN

Sounds like you're not really in touch with the real word. C has many benefits and it is super practical. Yes, you can write unsafe code, but safety isn't always your #1 priority. There are also tools you can use to identify issues, which will mitigate risks.

api May 6, 2024 View on HN

C is okay except safety. Look at the CVE lists and they are still full of memory errors and it’s 2024.The problem isn’t that good programmers can’t write good C code, though anyone can make a mistake. The problem is what happens as code ages, is worked on by other people, gets PRs merged, and so on. Bugs creep in and in an unsafe language nothing catches them.C also makes string processing hellish, but that could be fixed with libraries and isn’t necessarily the fault of the language.

pjmlp Aug 11, 2018 View on HN

Not at all.There is a world between every single string, array and numeric operation being a possible source of memory corruption and being forced to explicitly write unsafe code.I have been using mostly safe languages since the 80's.They only get in the way of cowboy programming, which is a very good thing for anyone that praises quality in software development.C would no longer be around if companies got properly sued for each CVE exploit.

nickpsecurity Apr 7, 2016 View on HN

That's basically how I see it. I can even trace many CVE's and crashes to C's safety issues. Currently, CompSci people are building reliable and secure HW for us but existing C code is difficult to integrate. Had it been Oberon or something, it would be a lot easier as the developers don't meddle directly with bits and memory as much.

uecker Dec 27, 2023 View on HN

There are plenty of other bugs causing CVEs, but there are certainly a lot caused by memory issues. I personally believe that C needs a safe mode, but also with existing tools (static analysis, sanitizers, etc.) one can improve things a lot. It is a bit unfair to compare billions of lines of old C code to newly written code in other languages. It would be interesting to compare modern C with modern tools to other languages. And, of course, all those billions of lines of old C code will contin

brokencode Jun 9, 2018 View on HN

Everybody makes mistakes, no matter how confident they are in C. And while there are numerous things written in C, there is also a continuous stream of bugs and vulnerabilities as well.That’s not to say that other languages are perfect, but there are much safer options that are still very fast, such as Rust, or even C# or Java.

atemerev Dec 21, 2015 View on HN

Writing secure software in C is just next to impossible. Memory corruption, arbitrary pointers, deep magic. Even pure assembly is more secure, as everything is explicit and well-defined there. There are lots of safer languages than C, and performance is not everything.

jdietrich Sep 23, 2017 View on HN

C and C++ simply weren't designed with safety in mind. Even with a good compiler and static analysis, security-critical bugs will slip through the net that simply wouldn't happen in other languages. It's not so much a question of whether it's possible to write safe C, but whether it's natural or easy. C is unsafe by default.

rychco Dec 29, 2023 View on HN

Why wouldn’t it be serious? C has been used to write safe, stable, & portable software for decades. Compiler warnings & static analysis tools have come a long way to preventing the vast majority of safety issues in (new) C projects.