Zig as an alternative to writing unsafe Rust
zackoverflow.dev
Zig as an alternative to writing unsafe Rust
1–10 of 230 posts
Re: Zig as an alternative to writing unsafe Rust
#2https://web.archive.org/web/20230307172822/https://zackoverf...
Re: Zig as an alternative to writing unsafe Rust
#3The link is down for me. Perhaps HN hug of death? Below is link to the site on the Wayback Machine. https://web.archive.org/web/20230307172822/https://zackoverf...
Re: Zig as an alternative to writing unsafe Rust
#4Re: Zig as an alternative to writing unsafe Rust
#5The benefits of Rust's (wonderful) model around references and lifetimes come at a significant cost to ergonomics when having to go into the Mordor of some C library and back. I usually find myself wishing I could have some macro where I just write in C and have it exposed as an unsafe back in Rust. I know I can do this by just writing a C dylib and integrating that, but now I've got two problems.
Even still, I prefer writing unsafe Rust to writing C. std::mem::ptr forces me to ask the right questions and reminds me of just how easy it is to fall into UB in C as well.
Re: Zig as an alternative to writing unsafe Rust
#6The link is down for me. Perhaps HN hug of death? Below is link to the site on the Wayback Machine. https://web.archive.org/web/20230307172822/https://zackoverf...
Re: Zig as an alternative to writing unsafe Rust
#7 var ptr: [*]u8 = @ptrCast([*]u8, &slice[0]);
the same as var ptr = slice.ptr;
?Or am I missing something
Re: Zig as an alternative to writing unsafe Rust
#8Re: Zig as an alternative to writing unsafe Rust
#9Writing basic data structures isn't a niche, esoteric edge case. There may be a crate that "solves" what you're trying to do. But does it rely on the std---(i.e., is it unusable for systems programming)? Is it implemented making gratuitous copies of data everywhere? Does it have a hideous interface which will then pollute all of your interfaces? Does it rely on 'unstable' features?
Then, there's the 'community.' It seems to consist solely of extremely online people who get a dopamine hit from both telling people they're doing things wrong and creating the most complex solutions possible. They do this under a thin veneer of forced niceness, but it's not nice at all.