3 ms·
And they believe Zig comptime wouldn’t do that? For the same inputs? I’d love an example.
by chaz72 12d ago
And they believe Zig comptime wouldn’t do that? For the same inputs? I’d love an example.
- weinzierl 12d agosin(x) can produce different results at comptime and runtime. In Rust there is no sin(x) at comptime for precisely this reason.
- chaz72 12d agoInteresting, 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 https://github.com/ziglang/zig/issues/24184 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.
- deleted 12d ago[deleted]
- vlovich123 12d agoTraditional stuff in this space are: * 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 12d agoI get it now. Important things but not things that I use often - hopefully addressed by 1.0.
- weinzierl 12d agoI'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.
- chaz72 12d agoI 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.
- vlovich123 12d agoI 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.
- tcfhgj 12d agoreproducible builds
- vlovich123 12d agobuild.rs checkmate
- tcfhgj 12d agonot mandatory
- vlovich123 12d agoNeither is using const
- tcfhgj 12d agocorrect, but it is desirable
- smj-edison 12d agoDoesn't comptime run under the target's float and endianness semantics? I need to check, but I believe they emulate the target when evaluating.
- vlovich123 12d agoEndianness 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
- dnautics 12d agoZig Comptime is softfloat