Get the latest tech news

How (memory) safe is Zig? (2021)


I keep seeing discussions that equate zig's level of memory safety with c (or occasionally with rust!). Neither is particularly accurate.

This is also why I don't expect to see a post-hoc static analysis tool for zig that approaches the same level of safety and flexibility that rust achieves - the library apis have to be designed with the proof system in mind. Eg in a serverless http handler where every request is a fresh wasm sandbox, a zig program that has runtime checks turned on and mostly relies on arena allocation (or even static pre-allocation) might be reasonably secure. This is untested as yet - we don't know how much safety vs how much performance overhead we'll get - but I expect to see this explored anyway for hardening legacy code and protecting against supply chain attacks, and then maybe we can extrapolate the results to zig.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of Memory

Memory

Photo of zig

zig

Related news:

News photo

In-Memory Ferroelectric Differentiator

News photo

Zig, the Ideal C Replacement Or?

News photo

Memory Safety Features in Zig