A 10+ year Haskell veteran argues Zig’s comptime replicates monads, newtypes, and typeclasses without a GC, and beats Rust on mean-time-to-surprise.
Key Takeaways
Zig’s comptime independently arrived at the Reader monad pattern: Zig 0.16’s IO redesign passes an allocator and io interface through structs exactly as Haskell’s IO monad does.
Newtypes, sum types (union(enum)), and typeclass-style dispatch (Eq(Point)) are all expressible via comptime structs with compile-time errors for missing implementations.
The author’s “mean-free-path” metric – lines written before implementation diverges from intent – rates Zig higher than Rust and C++, attributing this to the “no spooky action at a distance” design philosophy.
GC languages have a structural performance ceiling: heap-heavy pointer forests exploit 1995-era machines where CPU and memory timing were comparable; modern hardware has flipped that ratio ~10,000x in CPU favor.
Typeclass dictionary passing is explicit in Zig (EqPoint.eql) rather than compiler-injected; the author frames this as a feature, noting it resembles ML module systems.