Implementing a Struct of Arrays -- Barry Revzin
Data-oriented design is all about reorganizing data for better performance, and Andrew Kelley’s talk on the topic—especially his use of Zig’s MultiArrayList—offered a compelling real-world example. Inspired by that, this post explores how we can achieve a similar “struct-of-arrays” approach in C++26 using reflection to build a SoaVector<T> that separates member storage for improved memory locality and performance.
Implementing a Struct of Arrays
by Barry Revzin
From the article:
Recently, I watched Andrew Kelley’s talk on Practical Data Oriented Design. It goes into some of the architectural changes he’s been making to the Zig compiler, with pretty significant performance benefit. Would definitely recommend checking out the talk, even if you’re like me and have never written any Zig.
About halfway through the talk, he shows a way to improve his memory usage by avoiding wasting memory. By turning this structure:
const Monster = struct { anim : *Animation, kind : Kind, const Kind = enum { snake, bat, wolf, dingo, human }; }; var monsters : ArrayList(Monster) = .{};
into this one:
var monsters : MultiArrayList(Monster) = .{};
ArrayList(Monster)is what we could callstd::vector<Monster>, andMultiArrayList(Monster)now stores theanims andkinds in two separate arrays, instead of one. That is, a struct of arrays instead of an array of structs. But it’s a tiny code change.

A unique milestone: “Whole new language”
Templates are one of C++’s most powerful features, enabling developers to write generic, reusable code—but they come with a cost: notoriously verbose and opaque error messages. With the introduction of concepts in C++20, we can now impose clear constraints on template parameters and get far more helpful diagnostics when something goes wrong.
Some time ago, we developed a
C++ continues to refine its range library, offering developers more efficient and expressive ways to manipulate collections. In this post, we'll dive into three powerful range adaptors—
Modern C++ offers a variety of ways to work with key-value data structures like