Hacker News new | past | comments | ask | show | jobs | submit
oh boy. if only we had a language that could prevent this from happening. oh well, i guess there is nothing we can do but patch these things once they're discovered.
It's because of shitty cowboy C.

Writing *p++ = c;

to append to a buffer is just insanity, I don't know why so many people like to write "clever" code like this.

I have a buf_putc(struct buf *b, int c); which does bounds checking (and potentially growing the memory), and I've used this kind of abstraction for decades.

Same with "use after free" bugs, WHY are people malloc()ing and free()ing all over the place, and storing away pointers to things all over the place (people just looove their "objects" and stuffing pointers to things into structs and classes so now you have these insane lifetime couplings).

Ban pointer arithmetic, ban null terminated strings, ban malloc() and free() (and similar general purpose allocators), ban passing arrays without a length (and preferable have a struct ptrlen {} and pass it by value) and you eliminate 99.9999% of these bugs.

Multi threading in C is genuinely difficult because you get zero help from the compiler, but these low hanging bounds and lifetime problems can easily be eliminated with simple abstractions.

exactly, which is why I use ruby.
loading story #50556668
There was Java... then someone tried to optimize Base64.
"There's no way this could be prevented", says users of only programming language where it regularly happens
good developers simply would not have written these bugs.
loading story #50556134
Oh boy if you could develop a solution that would port C code over with completely safe rust semantics where feasible and without people having to clean up the disaster of a result, that would be nice, instead of you guys trying to demonstrate how superior you and your favorite language are. Because that is the only way you are going to port the world to Rust. Oh, and you have to support COBOL too. Probably a bunch of other old languages that have been around for longer than a lot of us have been alive.

Seriously, all these snarky posts about Rust being the god language really comes off as "look how utterly superior we are as Rust programmers and look how superior the Rust language is, this would never ever happen in Rust the god language". Yes, I'm annoyed by stuff like this.

That's all fine and good, but then why are people starting new projects in C in the year of our lord 2026!?
Possibly because C is the one universal language that literally everybody knows to a reasonable degree, LLMs included, and it supports any architecture imaginable. Or maybe they don't want to deal with Rust's compile times. I start projects in C++ because C++ still can do certain things that Rust cannot easily do/express.
If you insist on eating at the budget restaurant with the suspiciously long menu even after a series of food poisoning incidents, that’s your problem.

But the problem we all have with your predilection for salmonella-flavoured “food” is that inevitably you’ll then go swimming in the public pool and spread that around.

Programming languages aren’t generally a “personal choice”, they’re a matter of public safety and security.

We’re all finding out the consequences in real time of the choices made by others years or even decades ago.

actually rust devs are humble enough to understand their limitations and let the compiler help them out.

as for porting, well, llm go burrrrrr. we can even use llms to port gpl to mit.

If only we were not so busy here on HN posturing as wiser devs!