With Zig, you can write compile time code which can be used to implement generics, compile time checks, and provide really nice error messages.
This is amazing!
Programming language experts told Andrew Kelley, the creator of the Zig programming language, that having code which could run at compile time was a really dumb idea. But he went ahead and implemented it anyway. Years later, this has proven to be one of the killer features of Zig. In the Zig world, we call it
comptime, from the keyword used to mark code required to run at compile time or variables to be known at compile time.
And that is perhaps one of the things you got to constantly remind yourself while using Zig: It is just a form of C on steroids. You are not working with a high-level language. Zig doesn’t give you closures, automatic memory management, inheritance, or even interfaces. It is a bare-bones language, but
comptimecan often play games with your perception because it is so powerful.