Indices, not Pointers
Indices, not Pointers There is a pattern I’ve learned while using Zig which I’ve never seen used in any other language. It’s an extremely simple trick which - when applied to a data structure - reduces memory usage, reduces memory allocations, speeds up accesses, makes freeing instantaneous, and generally makes everything much, much faster. The trick is to use indices, not pointers. This is something I learned from a talk by Andrew Kelley (Zig’s creator) on data-oriented design. It’s used in Z