A lot of good stuff in there
A lot of good stuff in there
Posted Feb 15, 2025 16:40 UTC (Sat) by wtarreau (subscriber, #51152)In reply to: A lot of good stuff in there by mb
Parent article: New leadership for Asahi Linux
To me that is a good thing.
The thing is, there are plenty of cases where I *know* it's valid, e.g. because it has been validated a few lines before one way or another, or because it's guaranteed by contract in an API or anything. Instead I feel like the extra difficulty diverts me from doing the thing I was trying to do, and that constantly working around the compiler has serious chances of making me introduce bugs the same way I occasionally introduce some by trying to shut up an inappropriate gcc warning by rewriting code differently and making a mistake while the initial one was correct. I have strong doubts about the validity of all rust code in the wild in 10 years. Sure we'll see less overflows, but control bugs are very present as well and I suspect will be harder to spot (and sometimes even fix).
Posted Feb 15, 2025 16:56 UTC (Sat)
by mb (subscriber, #50428)
[Link]
Sure. And then you just have to tell the compiler about that knowledge. It's often as simple as calling unwrap(). Or sometimes even simpler by throwing in a question mark at the end.
In C you would also at least have to add a comment about where your assumption that an error can't happen comes from. In Rust you can just write that comment into code. For example with expect("The caller shall handle this").
>and that constantly working around the compiler has serious chances of making me introduce bugs
This "constantly working around the compiler" is just because you didn't learn the language.
Everybody who knows Rust knows that the compiler is extremely helpful when dealing with errors.
> I have strong doubts about the validity of all rust code
Based on what? Your non existing Rust experience?
Posted Feb 15, 2025 17:27 UTC (Sat)
by intelfx (subscriber, #130118)
[Link] (13 responses)
Sure. Then someday preconditions change, API contracts get violated (accidentally, or perhaps maliciously), and the CVE database grows a new entry.
If Rust forces you to code defensively, then that is a *very good thing*. That's the entire point.
Posted Feb 15, 2025 18:52 UTC (Sat)
by wtarreau (subscriber, #51152)
[Link] (12 responses)
But are you sure that it's not C that forces you to code defensively instead, given that you have no safety belt and you're on your own. If on the opposite I say "it compiled so it's safe", I quickly learn not to care anymore about defensive approaches.
Posted Feb 15, 2025 19:00 UTC (Sat)
by mb (subscriber, #50428)
[Link]
Posted Feb 15, 2025 19:19 UTC (Sat)
by intelfx (subscriber, #130118)
[Link] (9 responses)
I would argue that if we are honestly trying to say "C keeps us on our toes by virtue of being such a mess", it's not a good picture either way.
Posted Feb 16, 2025 22:22 UTC (Sun)
by mathstuf (subscriber, #69389)
[Link] (8 responses)
I understand the argument in the context of automating life-risky processes[1]. But the difference here is that Rust *isn't* guaranteeing "all bugs are gone". It is guaranteeing "the compiler will tell you when your code has *a class of problems*" so that you *can* focus on the logic bugs rather than having to think about "is this index calculation going to blow us up later?" Anything that has software for life-risky bits better have some level of logic bug detection (e.g., comprehensive test suite, formal verification, etc.), but this is needed *regardless* of the language unless one is actually doing their coding in Idris or something.
[1] A self-driving car that is wrong 50% of the time keeps the driver "in the loop" more effectively than a 75% accurate self-driving car, but once you hit some threshold, there's a bad overlap between human complacency with how accurate it *usually* is and hitting the gap in the AI behavior.
Posted Feb 16, 2025 22:33 UTC (Sun)
by intelfx (subscriber, #130118)
[Link] (1 responses)
That seems to align with what I was trying to say? If the only thing that keeps the codebase working is "bleed-over" of attention from memory correctness to logic correctness, that's not a sustainable practice either way (== we should instead be using tests and other stuff for logic correctness).
Posted Feb 16, 2025 23:07 UTC (Sun)
by mathstuf (subscriber, #69389)
[Link]
Posted Feb 16, 2025 22:58 UTC (Sun)
by jengelh (guest, #33263)
[Link] (5 responses)
A mechanism with 50% error rate is a mechanism that quickly gets disabled by the user. ("Fine, I'll do it myself" is effectively keeping the user in the loop, I give you that.)
Posted Feb 17, 2025 8:29 UTC (Mon)
by mathstuf (subscriber, #69389)
[Link] (4 responses)
Posted Feb 17, 2025 8:36 UTC (Mon)
by mathstuf (subscriber, #69389)
[Link] (3 responses)
Posted Feb 17, 2025 10:42 UTC (Mon)
by Wol (subscriber, #4433)
[Link] (2 responses)
It will (less so now) select illegal speeds, accelerate inappropriately, do all sorts of things. I tend to refer to it as a "granny racer" given that it tries to as fast as possible at every opportunity, yet is excessively cautious at others. It will accelerate, and then when it gets itself into trouble it will scream at me to brake ...
Cheers,
Posted Feb 17, 2025 11:18 UTC (Mon)
by mathstuf (subscriber, #69389)
[Link] (1 responses)
Posted Feb 17, 2025 12:58 UTC (Mon)
by Wol (subscriber, #4433)
[Link]
And it breaks a whole bunch of safe UI guidelines as well, such as allowing a driver to *override* the acceleration!
Cheers,
Posted Feb 16, 2025 11:41 UTC (Sun)
by khim (subscriber, #9252)
[Link]
Not possible. Not even remotely close. If you proved to the compiler that something is safe then you have proved to yourself that it's safe, as well. Precisely because compiler is dumb and doesn't understand many “subtle” ideas – you have to “dumb down” that proof of correctness that you have in your head to the level that compiler would understand. But compiler is also tireless and persistent. You couldn't convince it to like your code by writing long but incorrect explanation – like may happen with human reviewer. Nah. The most “defensively programmed” code that I saw was in Java or Python. Often “uselessly defensively programmed”. Because there you don't need to prove anything to anyone, any nonsense that you may write would be “memory safe” (by the virtue of virtual machine that decouples you from hardware) and then you have to program defensively and check everything 10 times because nothing (except these redundant checks) protect the integrity of your code from bugs.
A lot of good stuff in there
And if you were wrong with that assumption, it won't UB on you like C does.
It often suggests what exactly to change.
It explains exactly what is wrong and often even provides a link to an article about the error with examples of the coding error and examples how to fix it.
A lot of good stuff in there
A lot of good stuff in there
A lot of good stuff in there
A lot of good stuff in there
A lot of good stuff in there
A lot of good stuff in there
A lot of good stuff in there
A lot of good stuff in there
A lot of good stuff in there
A lot of good stuff in there
A lot of good stuff in there
Wol
A lot of good stuff in there
A lot of good stuff in there
Wol
> If on the opposite I say "it compiled so it's safe", I quickly learn not to care anymore about defensive approaches.
A lot of good stuff in there
