Live data from Hacker News

Zig as an alternative to writing unsafe Rust

zackoverflow.dev

41–50 of 230 posts

Re: Zig as an alternative to writing unsafe Rust

#41
post #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 pollu…

> Rust is the inverse of Perl: It makes the easy stuff hard. It's a bargain. Rust is pretty great, but it doesn't make some things easy because it would make everything else hard. This comment is amusing, mostly because Perl is so full of tradeoffs. Do you want to write something to do some string parsing quickly? Great language, maybe. Do you want to understand what you've written later? Maybe not so great. > Writin…

> And I'm not sure anyone loves this attitude either. Keep it technical.

Still, we, the Rust community, should take the high road and respond to the criticism by assuming that it's valid and asking what we can do better. I, for one, don't want developers to reject my Rust-based library because of the community's reputation, especially once my library has a C API.

Re: Zig as an alternative to writing unsafe Rust

#42
post #37

Earlier quoted context omitted.

On top of that Rust might be the ugliest modern language.

People keep saying this and I just do not get it . It's just… not that bad?

The core language is fine, but when you actually start building things you need to introduce lifetimes, all the traits that you polluted your interface with and then add on async, it gets out-of-hand quickly.

Re: Zig as an alternative to writing unsafe Rust

#44
post #8
post #6

Earlier quoted context omitted.

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

I did not know host file takes domain name patterns

By default, macOS and Linux don’t, but dnsmasq does and it’s quite popular. Don’t know about Windows

Re: Zig as an alternative to writing unsafe Rust

#45
post #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 pollu…

> Writing basic data structures isn't a niche, esoteric edge case Maybe it isn't an edge case (although it should be) it also isn't `easy` in a non GC'd language, and a huge source of memory bugs. I wouldn't say it makes the 'easy stuff hard' as much as the 'hard stuff appropriately difficult'.

Writing data structures is trivial in C/C++.

Re: Zig as an alternative to writing unsafe Rust

#46
post #17

Wait, the benchmark to find the 35th fibonacci number took 1.077s for the Zig VM vs 1.657s for the Rust VM? I realise that these VMs are going to be totally idiomatic Zig/Rust, with the most straightforward implementation possible, and little-to-no performance tuning, but even so - that's gotta be a typo, right? Or it's actually finding `fib(350)`? Or each "run" is actually finding `fib(35)` 100 (1000?) times?

It's intentionally using the naive 2^N solution to stress test lots of tiny function calls.

There is no way it will take a whole second regardless. Even when compiled in debug mode, it takes about 100 ms.

Try it here, I had Bing AI write it out - https://play.rust-lang.org/?version=stable&mode=release&edit...

Re: Zig as an alternative to writing unsafe Rust

#47

Earlier quoted context omitted.

> Writing basic data structures isn't a niche, esoteric edge case Maybe it isn't an edge case (although it should be) it also isn't `easy` in a non GC'd language, and a huge source of memory bugs. I wouldn't say it makes the 'easy stuff hard' as much as the 'hard stuff appropriately difficult'.

why should writing a basic data structure be an edge case? …what?

All of the "basic" data structures are already provided by either the standard library or crate ecosystem, so you'll rarely (if ever) need to write your own linked list or hash map from scratch.

I say "basic" in quotes because once you factor in the concurrency, ownership and memory safety concerns that are optional in other languages, but mandatory in Rust, there really isn't a simple implementation of these structures that is provably correct anymore.

Re: Zig as an alternative to writing unsafe Rust

#49

Earlier quoted context omitted.

On top of that Rust might be the ugliest modern language.

Agreed, using Rust is like switching a monster (C++) for another even worse. And notice that Rust is not even a mature language, it will get much worse. I will stay with C, thank you.

At least C++ is enormous and you can find a sane subset that you enjoy using. And C++ can be pretty safe with smart pointers.

Re: Zig as an alternative to writing unsafe Rust

#50

Earlier quoted context omitted.

> Writing basic data structures isn't a niche, esoteric edge case Maybe it isn't an edge case (although it should be) it also isn't `easy` in a non GC'd language, and a huge source of memory bugs. I wouldn't say it makes the 'easy stuff hard' as much as the 'hard stuff appropriately difficult'.

Writing data structures is trivial in C/C++.

As long as you don't care about UB or edge cases. Every time Rust makes something hard, it's forcing you to handle an edge case up front.
Post reply on HN