News for hackers. Stuff that matters.
Re:Low-Level Optimization with Zig by cornstalks on Sunday June 08, 2025 @09:30AM (#44216894)
(This is a reply to multiple sibling comments, not the parent)

For those saying unsafe Rust is strictly safer than C, you're overlooking Rust's extremely strict invariants that users must uphold. These are much stricter than C, and they're extremely easy to accidentally break in unsafe Rust. Breaking them in unsafe Rust is instant UB, even before leaving the unsafe context.

This article has a decent summary in this particular section: https://zackoverflow.dev/writing/unsafe-rust-vs-zig/#unsafe-...

Re:Low-Level Optimization with Zig by creata on Sunday June 08, 2025 @09:49AM (#44216992)
The author seems to mostly be talking about the aliasing rules, but if you don't want to deal with those, can't you use UnsafeCell?

Imo, the more annoying part is dealing with exception safety. You need to ensure that your data structures are all in a valid state if any of your code (especially code in an unsafe block) panics, and it's easy to forget to ensure that.

Re:Low-Level Optimization with Zig by Ygg2 on Monday June 09, 2025 @10:03AM (#44224646)
For those thinking unsafe Rust is harder than C. C standard defined just 216 unsafe rules, that you need to keep in mind at all times.