Zig needs to have list of compile time and runtime safety features on it's website

Zig seems to be different from other languages with manual memory management, i.e, it has a lot of compile time and runtime checks for safety unlike C.

Why not have a list of these safety features on the website.

I’ve been trying to find such a list, but there doesn’t seem to be such a list.

Thanks!

Hey @Oppbert, welcome to the forum!

I’d like to understand your post a bit better so we can talk about what information needs to be supported here (great timing, we just opened up a new Docs category that needs more content).

When we’re talking about safety checks, there’s a variety to choose from and some are dependent on the optimization level that you choose. There are checks deployed by the user and by the system, so I’d like some clarification here.

For example… there are general safety checks around things like integer conversion. The user doesn’t have to specify anything for those to get invoked.

A check that depends on optimization levels would be something like “unreachable” which triggers a panic in debug but gets compiled out in ReleaseFast.

Then there are checks that completely depend on the programmer. Zig offers utilities to handle some of these things (error unions and catch statements, for instance).

There’s also more advanced safeties in something like C that get toggled with something like --ffast-math… that’s another level of safeties we could talk about.

What type/level of safety check are you referring to, and what documentation have you looked at so far?

What I mean is not just as docs, but as a selling point for Zig.

For example for people who want to choose a language and want to know what features Zig has.

Since safety is a considered a selling point now a days due to Rust.

There were a few articles with incomplete information, but there is no list of Zig’s safety features.

Maybe even a table comparing different languages and their safety features.

I’d say safety goes back quite a long way - take languages like ADA which appeared 44 years ago. It really depends on what community/application we’re speaking to.

However, that doesn’t discount what you’re saying here. Some visual aids and comparisons could be a nice way to advertise some of the features that Zig has against C, for instance. C seems like a fair comparison as the differences between something like C++ or Rust starts to get quite large.

I will add though that Zig doesn’t sell itself as safety first - the safety that Zig is trying to achieve is by making ideas more easily expressible and information more complete (such as a more detailed taxonomy of pointer types and even the inclusion of defer). The heaviest safety aspect that gets talked about is “footguns” and the ongoing attempt to limit/remove them.

We could probably make an argument (and be right) that Zig doesn’t do enough to talk about those features in terms of how they inherently make code more safe by giving better control and information to the programmer.

But yeah, I’d be interested in seeing some visual aids and more side-by-side comparisons.

1 Like

There is a list with runtime safety features here:
https://ziglang.org/documentation/master/#Undefined-Behavior

3 Likes