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”
Registration is now open for CppCon 2025! The conference starts on September 15 and will be held
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.
Registration is now open for CppCon 2025! The conference starts on September 15 and will be held
C++’s One Definition Rule (ODR) can cause subtle and hard-to-detect issues when compile-time switches lead to inconsistent definitions across translation units. However, by using type aliases and template instantiation, we can sidestep these violations—giving each module its own definition without triggering undefined behavior.
Registration is now open for CppCon 2025! The conference starts on September 15 and will be held
Registration is now open for CppCon 2025! The conference starts on September 15 and will be held