All Topics
All Topics
Technology
Technology
Design
Design
Programming
Programming
Science
Science
News
News
Gaming
Gaming
Entertainment
Entertainment
Business
Business
Finance
Finance
Sports
Sports
Health
Health
Food
Food
Travel
Travel
Art
Art
Music
Music
Books
Books
Education
Education
Politics
Politics
Personal
Personal
No algorithm. No AI slop. No ads. Just RSS. Pro-human. Indie writers. Real journalism. Open web. Chronological. Hand toasted.

Using Indices Instead of Pointers for Memory-Efficient Data Structures in Programming

By

vitalnodo

9mo ago· 4 min readen

Summary

The article discusses a programming technique learned from Zig language creator Andrew Kelley, which involves using indices instead of pointers in data structures. This approach reduces memory usage, minimizes allocations, speeds up access, enables instant freeing, and generally improves performance. The technique is used in Zig's compiler for memory-efficient ASTs and represents a data-oriented design pattern that the author hasn't seen in other languages.

Key quotes

· 3 pulled
The trick is to use indices, not pointers.
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.
It's used in Zig's compiler to make very memory-efficient ASTs, and can be applied to many data structures.
Snippet from the RSS feed
Jul 15, 2025

You might also wanna read