Find Related products on Amazon

Shop on Amazon

Having your compile-time cake and eating it too

Published on: 2025-06-20 06:54:10

Having your compile-time cake and eating it too Disclaimer In this post, I assume: You know a little bit about Rust. You know a little bit about Zig. I'll be using my own syntax to express ideas from both of these languages. Why "types are just values" doesn't work As programmers, we like it when our programs run well. Type systems are there to help us with that. They track the types of values in our programs before we run them, which not only saves us from runtime crashes but enforces guidelines for writing good code. Normally, type syntax (and logic) is distinct from the rest of a programming language. A rare exception to this rule is Zig, where types are just treated as values, and compile-time (comptime) operations on those values are allowed. That's all the type system is. In a normal language, the List[Int] type is a very abstract idea. But in Zig, List(Int) is just a regular function call where you're inputting a Type and getting a Type back. Simple, right? Well, if w ... Read full article.