logoalt Hacker News

mijoharasyesterday at 12:12 PM2 repliesview on HN

I'm not super experienced with zig, but I always think that in the same way that rust forces you to think about ownership (by having the borrow checker - note: I think of this as a good thing personally) zig makes you think upfront about your allocation (by making everything that can allocate take an allocator argument.).

It makes everything very explicit, and you can always _see_ where your allocations are happening in a way that you can't (as easily, or as obviously - imo) in rust.

It seems like something I quite like. I'm looking forward to rust getting an effects system/allocator api to help a little more with that side of things.


Replies

silon42yesterday at 12:42 PM

The problem is deallocation... unless you tie the allocated object to an arena allocator with a lifetime somehow (Rust can model that).

show 1 reply
IshKebabyesterday at 4:49 PM

That's true and I liked the idea of it until I started writing some Zig where I needed to work with strings. Very painful. I'm sure you typically get a bit faster string manipulation code than what you'd get with Rust but I don't think it's worth the cost (Rust is pretty fast already).

show 1 reply