4 ms·
"The revolution will not be televised". The beginning of the end of use-after-free, buffer overflows, stack smashers, et al will be when we as a community fina
by xenadu02 10y ago
"The revolution will not be televised".
The beginning of the end of use-after-free, buffer overflows, stack smashers, et al will be when we as a community finally accept that C is a terrible language, impossible for ordinary humans to reason about, and must be abandoned. Only when we begin to accept that truth will we all get serious about moving away from it.
For many years the response has been that "C is fine" or some variant of "humans will be better programmers in the future" both of which are demonstrably false.
No one questions the wisdom of paramtaraizing SQL. No one questions the wisdom of not writing your own crypto. Yet despite the mountains of evidence, wasting billions (yes BILLIONS) of man-hours and dollars, and even lives lost there is still resistance to the idea that C needs to die ASAP.
So as long as there are posts like yours our job of educating and persuading isn't finished and that's extremely important if we have a hope of actually making this desperately needed change.
If you still doubt let me go ahead and make a prediction: before the end of the year there will be another RCE exploit in the Linux kernel discovered and a different one will be written, code-reviewed, and committed but not discovered until later (but within 5 years). I'm happy to put $1,000 on this wager.
- crististm 10y agoActually, it is still possible to use C as a higher than assembly target language for compilers.
- MaulingMonkey 10y agoWhile I'm really interested in this for making languages available everywhere (tm), basic things like signed integer overflow being undefined behavior make me question is C is fit for purpose even here.
- jjnoakes 10y agoSince you are generating the C code, you can generate the appropriate checks where needed to avoid such undefined behavior too.
- MaulingMonkey 10y agoWhich is the one thing keeping it in the running. The problem is this line of reasoning doesn't generally hold up when applied to C codebases (because in practice statistics catches up with you eventually) and C code generators, in effect, happen to contain an admittedly small but rather obfuscated C codebase. Moreover, you must always include such checks - manually crashing on e.g. null pointers even if you'd be entirely satisfied with a segfault - just to avoid the optimizer potentially going apeshit on your code. Which can have... poor effects on program performance.
- jjnoakes 10y agoIf you are writing a code generator, it all depends on the source language. If, for example, your source language doesn't have NULL pointers, then you don't have to waste cycles checking them in C.
- progman 10y agoIndeed. That's what Nim and Rust (for instance) can do to ease porting to other platforms. Even safety critical applications can be written in C by using tools like FramaC. https://frama-c.com https://frama-c.com
- qwertyuiop924 10y agoI've got no problem admitting that C isn't good enough in most cases, and should probably die. I know that's true. I'm just sick of the annoyingly smug comments about it that pop up like mushrooms on HN. If you're posting here, you're more often than not preaching to the choir.
- deleted 10y ago[deleted]
- GrumpyYoungMan 10y ago>The beginning of the end of use-after-free, buffer overflows, stack smashers, et al will be when we as a community finally accept that C is a terrible language, impossible for ordinary humans to reason about, and must be abandoned. 1) All the complaints you have apply equally well to assembly language, yet assembly language is all that the CPU understands. Somebody always has to deal with the low level complexity of writing the foundational software constructs necessary to build safe environments and C is still the most natural mapping to varied assembly languages that we have. 2) Nothing else will fit for many embedded systems. Your choices are C or assembly language. What safe environment/language are you going to fit into a microcontroller with 1kB of RAM? (And, yes, maybe Rust or one of the other proposed system language replacements will be better than C someday, but that someday isn't today.)
- dragonwriter 10y ago> All the complaints you have apply equally well to assembly language, yet assembly language is all that the CPU understands. No, machine code is all that the CPU understands. Assembly language is source code that gets converted into machine code by an assembler.