Hacker News new | ask | show | jobs
by wmedrano 15 days ago
Zig gives you more control than Rust, which should theoretically lead to a higher performance ceiling.

There's not much magic in Zig. Keep hitting goto-definition and you can eventually see the OS switch statements and syscalls.

1 comments

Neither Rust nor Zig give you any more control than the other. If you want raw pointers or inline assembly, Rust supports that.
Technically true, but unsafe Rust is much harder to deal with because it makes assumptions (sometimes very non-obvious) regarding aliasing that Zig does not. You might think you can avoid problems by using T* rather than T&, but every accessible local is effectively a T& so it's still very easy to do something you're not supposed to.
> every accessible local is effectively a T&

No, I'm not sure where you heard this but this is certainly not the case. If I have an i32 on the stack in Rust, there are no aliasing invariants that need to be upheld. You do, in fact, avoid problems in unsafe Rust by just using raw pointers instead of references. The idea that "unsafe Rust is harder to deal with than {Zig, C, C++}" is a long-outdated notion from old versions of Rust, before there was a dedicated way to produce a raw pointer without first producing an intermediate reference.