Hacker News new | ask | show | jobs
by winter_squirrel 1483 days ago
As someone who uses both for different personal projects:

- I use zig as my build system for both rust, zig, C libraries and linking since the build system works really well for this purpose

- When I need to write applications or libraries that can benefit from compile-time code, I always try and use zigs since it's much easier to use comptime then a combination of rust macros and generics

- I like the zig async story a lot better. Or at least it's much easier to wrap my head around and write code in compared to rust + tokyo

On the other hand, sometimes I know a project will benefit from the borrow checker or I want to use some of the awesome rust crates that the community made and I'll use rust instead.

1 comments

Does a really short summary of this read kind of like, "zig is a modern c, but I like using rust as a modern c++"?

Agree, Tokio is a little tricky for people new to rust no doubt, but it's tricky for a reason. It's saving lives in production.

Just FYI: things that are actually "saving lives" are probably realtime applications, which need things like deterministic execution time, no allocation from the os, bounded memory usage, which rust generally does not give you without a ton of effort.
This is actually the frame of reference I've taken to giving most folks. Zig is to C what Rust is to C++ in my mind. Is there a lot of overlap between all 4? Absolutely. But devs still choose C over C++ (and Rust) in some cases, and I think it'll be similar for Zig
Thanks for explaining, I really appreciate it.
Yes, but Rust offers something more than just modernizing C++. The borrow checker provides something entirely new that has the potential to make a huge impact.
Just semantics, but I think the borrow checker is part of modernizing C++.

(The way to manage memory in C++ and C is to opt in to a memory management pattern... hopefully you've chosen a good pattern and hopefully you follow it consistently. Patterns are generally backed by utilities and primitives that are hopefully correct, complete, and hopefully make it relatively easy to follow the pattern consistently. Hopefully you can get a linter to help you too. In a sense Rust takes the same approach, but was implemented from the ground up to eliminate all the gaps so you essentially don't have to hope to successfully bridge the gaps yourself.)

Can you elaborate on the savings lives part? I sense a good story, would love to hear.