Comment by nvme0n1p1
16 hours ago
What's your source for this? Comptime Zig code can do pointer casts and whatnot, all emulated as if run on the target bitness/endianness/etc. And any operations that are undefined on the target platform result in a compile error. I've never had an issue cross-compiling.
Endianness and pointer casts are the mechanical part and I would expect Zig to emulate them correctly.
Other parts, like floats are harder. This is where a difference shows. Rust is like: "Sorry, since we cannot uphold our guarantees, no transcendentals for you at comptime ", whereas Zig is chill about that and let you have your transcendentals even if results may differ between comptime and runtime. Different mindsets.
The guarantees could be provided, if there would be a way to ensure that the compiler uses the same standard math library that is used by the executable program that is created.
This could be done, for instance, if the standard math library would be dynamically linked into the compiler, so the same library would be available for the compiled program.
If you disregard performance, yes. Unfortunately forcing softfloat everywhere would result in abysmal performance, so this is not an option.
Just to note, Rust has had compile-time floats for a while now, but yes.
Yes, but no transcendentals on floats. You can add them and the like but you cannot calculate the sine.