logoalt Hacker News

lionkortoday at 12:55 PM2 repliesview on HN

Zig is in the space of languages where an abstraction that decides that memory allocations are irrecoverable is not good enough.

If you work in an environment where memory allocations can't fail or can't be handled if they fail, you might not want to use Zig, or C for that matter. Not every language should be designed to live in the space of "somehow low level but also a good choice for your basic web backend", like Rust.


Replies

kibwentoday at 2:24 PM

Rust doesn't stop you from checking if memory allocation has failed. Its libstd provides many operations that don't bother to surface memory allocation failure (for the reasons given above), but that's why Rust provides a libcore that does no allocation, while continually working to push more things down from libstd into libcore, while providing alternative APIs in libstd to let you handle allocation failure if you know you actually need to.

show 1 reply
Panzerschrektoday at 1:56 PM

> If you work in an environment where memory allocations can't fail or can't be handled if they fail, you might not want to use Zig,

It's most of environments. Basically any program running under a modern OS. So, why do this language exists, if its practical applicability is so small?

show 2 replies