Hacker News new | ask | show | jobs
by hansvm 1487 days ago
I write Rust for $day_job and Zig for fun. Rust is great, but if I had to rip on a few places where it's lacking for some applications: Zig maintains a small language footprint, is easier to interop with C, and makes it readily apparent when your code is doing anything non-trivial. To make that concrete:

- The small footprint in Zig enables fast compilation (and getting faster) and fast feedback cycles.

- Arbitrary nastiness can happen using From and other traits in Rust, and the tendency to shadow names and rely on type inference can make that unpleasant to track down. In Zig you'd be forced to make a choice (for any non-trivial type) at the return or call site of how you were going to convert things.

- If you want to use the stdlib and have any non-trivial control over how objects are allocated you're in for a rough time in Rust (say, a circular buffer backing some objects and a reusable arena for others). You'll probably be reinventing a lot of wheels.

- Similarly with issues like implicit locking in stdout. It's executing a syscall per line anyway, but the lock can inadvertently make contended writes 1000x slower, so suddenly logging in multithreaded code needs a dedicated logger, and not any of the common options since those fall back to the locking stdout we're trying to avoid.

1 comments

Rust probably had a fairly small "language footprint" when it was only a few years old with no production use cases as well. I've used both in some small hobby projects. I like writing zig significantly more than rust, but we'll see how long the language remains small and compact.
On the contrary, it had a larger one because it had green threads which require an entire runtime (similar to Go).
I first tried rust in 2015[1]. It was my first serious attempt at rust.

The language was not small whatsoever at the time. It was not fun.

[1]: https://github.com/motiejus/makelua/tree/rust

I recommend trying it again. Consider how old the language is, 7 years is a really long time ago.

It may not be the smallest language, but, it compiles pretty tightly.