Hacker News new | ask | show | jobs
by uecker 16 days ago
One can abstract buffer handling away in C just fine, eliminating all those problems. I don't know why programmers insist on open-coding low-level buffer management.
1 comments

Yes, of course, this isn’t C, this is just another case of people writing C wrong.
Perhaps we could use another language, where it's not so easy (or possible) to write it wrong?
It is also easy to write it wrong in other languages. The coreutils rewrite had hundreds of issues, cloudflare brought down half of the internet because in the magic language where nothing can go wrong due to the advanced type system someone used an unchecked .unwrap (but this does not count, because this was Rust and not C - so could not possibly be the fault of the language, so only the programmer is to blame), and just recently Microsoft found a couple of memory safety issues in Rust's standard library. And let's better not talk about the supply chain.
Most of those were crashes. The unsoundness in the standard library is a problem, but I am yet to see a practical impact of them.

Rust people do not shy away from criticism. But rust code typically need not worry about mismatched buffer sizes at library boundaries. Especially when it comes to rce enabling bugs.

And yet, for any of those, the C world still get "why do we still use this language?" comments.
It takes active effort to misuse Rust, whereas it takes a lot more effort to not misuse C.