Live data from Hacker News

Zig 0.5.0 Release Notes

ziglang.org

51–60 of 80 posts

Re: Zig 0.5.0 Release Notes

#51

Earlier quoted context omitted.

> For example, in Zig both signed and unsigned integers have undefined behavior on overflow, contrasted to only signed integers in C. Huh, that's a strange choice. What's the safety story for Zig? Are these always undefined, or is that only in an "unchecked" build?

The latter. Zig actually kinda does define this behavior as "`a + b` shall not overflow" and inserts checks in debug and safe builds for it. To get overflow, which zig defines as wrapping overflow, you use a different operator and no check is inserted "`a +% b`". For speed optimized builds, unless you've explicitly told the compiler to insert checks in that scope, it will turn the checks into nops. So, while it is te…

We do the same thing in Rust, but I think that characterizing this as UB is misleading, personally. We created a new category, "program error", for this, to distinguish from UB proper.

I'm not sure if Zig inherited the defined/implementation defined/undefined hierarchy from C and C++ though.

Re: Zig 0.5.0 Release Notes

#52
post #50

Earlier quoted context omitted.

They got rid of the % operator for error propagation for one.

That's funny; one selling point of rust is the easy propagation of errors thanks to the '?' but zig removed the % which was the equivalent I think

You can still propagate errors in zig using ? like in rust. they just simplified it

Re: Zig 0.5.0 Release Notes

#53
post #50

Earlier quoted context omitted.

They got rid of the % operator for error propagation for one.

That's funny; one selling point of rust is the easy propagation of errors thanks to the '?' but zig removed the % which was the equivalent I think

The operator wasn't removed, it was replaced by a keyword. See the documentation on error handling: https://ziglang.org/documentation/master/#catch

Re: Zig 0.5.0 Release Notes

#54

> Speaking of performance, Zig is faster than C. These kinds of claims make me so dubious for a language. Also who is trying to switch from C to get an ever-so-slightly performance improvement? That use-case goes to specialized hardware such as FPGAs.

Whether the claim hold up or not. If you developed a language that's faster than C, would you not advertise that as a feature?

I would, first of all, call bullshit on this claim. A language can't be "faster than C". Comparing a good implementation with a bad C implementation is where these claims come from.

Re: Zig 0.5.0 Release Notes

#55

Earlier quoted context omitted.

The latter. Zig actually kinda does define this behavior as "`a + b` shall not overflow" and inserts checks in debug and safe builds for it. To get overflow, which zig defines as wrapping overflow, you use a different operator and no check is inserted "`a +% b`". For speed optimized builds, unless you've explicitly told the compiler to insert checks in that scope, it will turn the checks into nops. So, while it is te…

We do the same thing in Rust, but I think that characterizing this as UB is misleading, personally. We created a new category, "program error", for this, to distinguish from UB proper. I'm not sure if Zig inherited the defined/implementation defined/undefined hierarchy from C and C++ though.

There's a task to rename UB to illegal behavior: https://github.com/ziglang/zig/issues/2402

As well as some followups to see if Zig can detect all of these errors: * https://github.com/ziglang/zig/issues/1966 * https://github.com/ziglang/zig/issues/2301

Re: Zig 0.5.0 Release Notes

#56
post #54

Earlier quoted context omitted.

Whether the claim hold up or not. If you developed a language that's faster than C, would you not advertise that as a feature?

I would, first of all, call bullshit on this claim. A language can't be "faster than C". Comparing a good implementation with a bad C implementation is where these claims come from.

> A language can't be "faster than C".

Why not? For instance, with current hardware, the good use of SIMD is critical. If you can't write vectorized code in (standard) C while you can do it in another Language, that would be a "faster" language. Same for other language features that enable faster code: Compile-time computations, better memory model with different pointer aliasing semantic, ...

Re: Zig 0.5.0 Release Notes

#57
At the very first glance: what is wrong with

    function xxx()
instead of

    fn xxx()
what are we trying to save here?

Also would be nice to do import instead of @import. More readable I think.

Afraid to dig deeper as I do not have time to play with the languages that I can not yet use in production.

Re: Zig 0.5.0 Release Notes

#58

Earlier quoted context omitted.

The latter. Zig actually kinda does define this behavior as "`a + b` shall not overflow" and inserts checks in debug and safe builds for it. To get overflow, which zig defines as wrapping overflow, you use a different operator and no check is inserted "`a +% b`". For speed optimized builds, unless you've explicitly told the compiler to insert checks in that scope, it will turn the checks into nops. So, while it is te…

We do the same thing in Rust, but I think that characterizing this as UB is misleading, personally. We created a new category, "program error", for this, to distinguish from UB proper. I'm not sure if Zig inherited the defined/implementation defined/undefined hierarchy from C and C++ though.

Undefined as in undefined by language spec. There are various processor implementations that have different results that are often quite useful. Would you preclude their use?

Re: Zig 0.5.0 Release Notes

#59
post #54

Earlier quoted context omitted.

Whether the claim hold up or not. If you developed a language that's faster than C, would you not advertise that as a feature?

I would, first of all, call bullshit on this claim. A language can't be "faster than C". Comparing a good implementation with a bad C implementation is where these claims come from.

You can dispute Zig, but in practice there is FORTRAN that is faster for many math procedures.
Post reply on HN