Things Zig Comptime Won't Do
a year ago
- #programming
- #Zig
- #comptime
- Zig's comptime feature is designed to be restrictive and does not allow host leakage, ensuring comptime code behaves consistently across different compilation targets.
- Zig does not support dynamic source code generation (No #eval), instead relying on partial evaluation/specialization for similar outcomes.
- Unlike some languages, Zig does not support Domain-Specific Languages (DSLs) or custom syntax in comptime functions, operating strictly on Zig values.
- Zig requires all type meta programming to be specialized away, with no Runtime Type Information (RTTI), ensuring types as values only exist at compile time.
- Comptime in Zig cannot extend the API of generated types; methods cannot be added to generated types, keeping their API hand-written and predictable.
- Zig comptime does not allow any Input/Output operations, making compile-time evaluation hermetic, reproducible, safe, and cacheable, though external tools can be used for code generation.