We have Traits at Home

2026-10-03 · zig, traits, polymorphism, abstraction

I have had more time recently to write code in Zig, and it has been good for my soul. I wanted to share some insights I have arrived at regarding abstractions in Zig, including some techniques that I have found useful but not seen employed more broadly.

Considerable[1] ink[2] has[3] been[4] spilled[5] on Zig Interfaces, and justifiably so. While not a language feature, interfaces are the de-facto way of implementing runtime polymorphism in Zig. Yet[6] more[7] has been said about zig's comptime, and how it may be leveraged to avoid the performance woes of dynamic dispatch and write slick, data-oriented code.