1. Tooling (as an extension to the mentioned IDE support point). Zig and Rust are both praised for their tooling and I think rightfully so. The C/C++ interop story and the cross-compiling story in Zig are great. From the standpoint of a working practitioner though I think Rust is way ahead. Not surprising given that Zig is much younger, but something to keep in mind.
2. Compile Time Stuff: Here Zig is praised and Rust not so much. I think this is undeserved. Rust has much higher aspirations for their compile time features, namely that outcome must be identical regardless when the code runs. This is a very useful property but makes the task much harder and fundamentally incomparable with Zig comptime.
Interesting, I hadn’t run across that but that’s probably just my problem domain. I did find this bug that looks like it was resolved a year ago <a href="https://github.com/ziglang/zig/issues/24184" rel="nofollow">https://github.com/ziglang/zig/issues/24184 and I have also read they are doing some other work on floating point that will hopefully address other cross-platform inconsistencies.
I'm not sure there is something to be addressed. Zig has just a different approach and Zig people different expectations.
In Rust we can expand what is possible at compile time without breaking existing code because we took a very careful approach only stabilizing what we are sure about. Some things will probably never be possible at compile time in Rust.
Zig is much more powerful but that also means they cannot take stuff away without breaking existing code and making comptime more restricted. So it is unlikely Zig will ever become like Rust in that regard, but that is ok - just different approaches.
I hear you but I’m not sure it’s as dramatic as that, it’s also been quite predictable in my use over the last few years since I haven’t happened to use floating point or different endianness.
I think the Rust approach is incorrect - if the runtime behavior can change based on the machine that the code gets run on, why is it so important the build time behavior has such a restrictive definition? Especially considering build.rs can be used to bypass that definition anyway. It feels like a weird cut to make that I can’t figure out the understanding for. It feels like it inherited the const philosophy of c++11 without reexamining if it’s actually a good idea.
Doesn't comptime run under the target's float and endianness semantics? I need to check, but I believe they emulate the target when evaluating.
Endianness yes, but float no. They just force software ieee754. It gives you exact bit accuracy on all build machines but it results in math that would differ between build time and run time depending if the function is evaluated as const or not
weinzierl · · focus · HN ↗
1. Tooling (as an extension to the mentioned IDE support point). Zig and Rust are both praised for their tooling and I think rightfully so. The C/C++ interop story and the cross-compiling story in Zig are great. From the standpoint of a working practitioner though I think Rust is way ahead. Not surprising given that Zig is much younger, but something to keep in mind.
2. Compile Time Stuff: Here Zig is praised and Rust not so much. I think this is undeserved. Rust has much higher aspirations for their compile time features, namely that outcome must be identical regardless when the code runs. This is a very useful property but makes the task much harder and fundamentally incomparable with Zig comptime.
chaz72 · · focus · HN ↗
bruckie · · focus · HN ↗
chaz72 · · focus · HN ↗
weinzierl · · focus · HN ↗
chaz72 · · focus · HN ↗
[deleted] · · focus · HN ↗
[deleted]
vlovich123 · · focus · HN ↗
* floating point differences between the build machine and the target. By far the most common
* endiannes - code assumes little median runs on big endian
There’s other more subtle issues that can crop up but those are the big two.
Not saying I agree though - those can happen anyway when you run on two different machines anyway.
chaz72 · · focus · HN ↗
weinzierl · · focus · HN ↗
In Rust we can expand what is possible at compile time without breaking existing code because we took a very careful approach only stabilizing what we are sure about. Some things will probably never be possible at compile time in Rust.
Zig is much more powerful but that also means they cannot take stuff away without breaking existing code and making comptime more restricted. So it is unlikely Zig will ever become like Rust in that regard, but that is ok - just different approaches.
chaz72 · · focus · HN ↗
vlovich123 · · focus · HN ↗
tcfhgj · · focus · HN ↗
vlovich123 · · focus · HN ↗
tcfhgj · · focus · HN ↗
vlovich123 · · focus · HN ↗
tcfhgj · · focus · HN ↗
smj-edison · · focus · HN ↗
vlovich123 · · focus · HN ↗
dnautics · · focus · HN ↗