Comparative unsafety
flak.tedunangst.com
Comparative unsafety
1–10 of 99 posts
Re: Comparative unsafety
#2Actually, he wrote some Rust and some C code wrapped in Rust.
> I was writing an smtp server... the kind of smtp server you'd write in two days.
(sigh)
> The error would have been detected far sooner had I not been lazy and checked the return value of chown (for a file not found error). But [excused here]
You can't, and mustn't avoid C error checking when writing C code, even if it's wrapped in Rust.
I was a TA in a first-semester course in C programming for several years, and one of the harder things to inculcate is how return value checking is not optional. It's very tempting to assume your standard library function just works, always.
Re: Comparative unsafety
#3Very poetic. Are you Russian?
Re: Comparative unsafety
#4First thing I'd try would be to pass "~0" instead of "-1". Would that work? (Looks like in Rust that would be "!0". I don't know anything about Rust.)
Re: Comparative unsafety
#5Switching away from my browser and back again causes the page to re-render, losing my place as it did so. Just awful!
Re: Comparative unsafety
#6Re: Comparative unsafety
#7> I wrote some rust code. Actually, he wrote some Rust and some C code wrapped in Rust. > I was writing an smtp server... the kind of smtp server you'd write in two days. (sigh) > The error would have been detected far sooner had I not been lazy and checked the return value of chown (for a file not found error). But [excused here] You can't, and mustn't avoid C error checking when writing C code, even if it's wrapped…
> You can't, and mustn't [...]
It doesn't really sound like he's trying to excuse anything. Quote the intro more fully:
>>> I used unsafe. It was unsafe. After months of contemplating this unfortunate result, I've found someone else to blame.
Re: Comparative unsafety
#8As someone who is used to working in a language where one absolutely cannot hit memory safety issues or undefined behaviour, you can be damn sure that I'm going to read all the relevant documentation and double/triple the invariants of any unsafe code I write in Rust (and maybe even get it reviewed by someone else).
In some ways unsafe blocks in Rust are more unsafe than the equivalent C or C++ code because you have to uphold Rust's more stringent safety guarantees (e.g. no aliasing of mutable references), but they come with the saving grace that you don't need them very often, so you can afford to really take your time and implement them thoroughly.
Re: Comparative unsafety
#9Re: Comparative unsafety
#10This has the most toxic UI I've seen in my life. Switching away from my browser and back again causes the page to re-render, losing my place as it did so. Just awful!