News for hackers. Stuff that matters.
Re:Why Not Just Do Simple C++ RAII in C? by dralley on Thursday May 23, 2024 @12:19AM (#40450421)
And yet somehow languages such as Rust, which have no UB (in the safe subset) manages to be within 5% of C and often faster in both real-world codebases and microbenchmarks.
Re:Why Not Just Do Simple C++ RAII in C? by fooker on Thursday May 23, 2024 @01:35AM (#40450832)
It’s just a change in jargon for ‘marketing’ reasons.

For example: Rust will silently wrap signed integers in release mode even when it’s considered a bug and crashes in debug mode.

Re:Why Not Just Do Simple C++ RAII in C? by Slyfox33 on Thursday May 23, 2024 @01:49AM (#40450929)
Signed overflow is not UB in rust. That's not the same thing at all.
Re:Why Not Just Do Simple C++ RAII in C? by fooker on Thursday May 23, 2024 @01:51AM (#40450932)
It’s not.

You have missed my point.

Re:Why Not Just Do Simple C++ RAII in C? by rcxdude on Thursday May 23, 2024 @05:39AM (#40452572)
That is pretty much the only example where there's a compromise between performance and correctness as a difference between release and debug mode, and note that it's a) not undefined behaviour and b) does not violate any of rust's safety guarantees.

Every other example you mention is done by rust in release mode and the performance impact is minimal, so I would say it's a good counterexample to your claims that defining these things would hamstring performance (signed integer overflow especially is an obvious no-brainer for defining. Note that doesn't necessarily mean overflow checks! Even just defining the result precisely would remove a lot of footguns).