Live data from Hacker News

Zig as an alternative to writing unsafe Rust

zackoverflow.dev

1–10 of 230 posts

Re: Zig as an alternative to writing unsafe Rust

#4
post #2

The 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...

Maybe you don't have *.dev lookups working properly?

Can confirm that I can pull the site here.

Re: Zig as an alternative to writing unsafe Rust

#5
I buy the premise that Zig is better if you know you will have lots of pointer arithmetic going on. Having written a fair amount of unsafe C interop code in Rust, I feel like these critiques of the ergonomics are valid. The new #![feature(strict_provenance)] adds a new layer of complexity, that, I hope, improves some of this experience while adding safety. Rust's benefits are not free.

The 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

#8
post #6
post #2

The 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...

Check your hosts file, you might be mapping *.dev to localhost

I did not know host file takes domain name patterns

Re: Zig as an alternative to writing unsafe Rust

#9
This pretty much mirrors my experience. Rust is the inverse of Perl: It makes the easy stuff hard.

Writing 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.

Post reply on HN