Footguns
Footguns
Posted Jul 18, 2021 12:09 UTC (Sun) by khim (subscriber, #9252)In reply to: Footguns by excors
Parent article: Rust for Linux redux
That's pretty nice example. But it shows all the issues discussed in the well-known rant perfectly.
First: it doesn't require you to make surprising and crazy assumption that p
and q
point to distinct objects. So it's not quite the same optimization as I'm not talking about.
Second: it can be easily fixed by just adding one restrict - and that works even for a compiler which doesn't know anything about realloc
.
Sounds “infeasibly complicated”… to whom? To someone who doesn't want to compile standard-conforming programs correctly? To someone who feels C and C++ develpers are slaves of the compiler and would have to follow all the warts of it no matter what?
Adding 10 (20? 100?) lines of code was “infeasibly complicated”, but forcing all users of realloc
to review and fix their code is not?
That's precisely an attitude which makes C and C++ unsuitable for any purpose.
That's already a very-very troubling and hard to accept attitude. But at least when there was that “holy scripture”, that standard, which everyone was supposed to obey… it looked doable.
Now, when we know compiler developers wouldn't stop their work on sabotaging perfectly working programs (yes, I know: usually it's considered polite to say something like compiler writers really like the freedom that aggressive undefined behavior gives them to optimize, and are reluctant to cede any ground that might impact performance but I'm rude guy and when I see that something is black I call it black) we need to start thinking about escape plan.
Not necessarily Rust. It may be Ada, C# or even, gasp, Java or JavaScript.
But we have to start working on migration. Now. Till we still have time.
It's time to declare C and C++ a liability and start working on making sure they would join PL/I in the annals of history. Maybe then people would learn something.