3 ms·
> Only time will tell if comptime is the "greatest thing since sliced bread" or not. Common Lisp user here. Am I missing anything that Zig has in the compile t
by LispSporks22 3y ago
> Only time will tell if comptime is the "greatest thing since sliced bread" or not.
Common Lisp user here. Am I missing anything that Zig has in the compile time department?
edit: Also, does the code in the comptime block have to be valid Zig?
- kps 3y agoIt only has to be syntactically valid (parseable).
- kllrnohj 3y agoPersonally I think comptime is a questionably design and is something both Rust & C++ did much better. In C++ branches that don't have to "compile" are explicitly marked as such with `if constexpr`. In Rust you've got macros that are also explicit with required `!`. In Zig any branch can be a ticking code rot time bomb, just like it was with C #ifdefs. It's better in Zig in that it at least has to parse and so you've got fewer blatant problems, but the category of problems of "I flipped DEBUG from `false` to `true` and now I have dozens of build errors to go fix" is still there. And you really don't have any warning signs other than "this is branching on something that might be known at compile time" But honestly that's also my general impression of Zig as a whole. It's very definitely a "better C", not something that's necessarily good/competitive with the broader state of the ecosystem. It's like a love letter to C, completely with many of the same general problems that C is known to have and that other languages have addressed.