Zig NEWS

loading...

Discussion on: Struct of Arrays (SoA) in Zig? Easy & in Userland!

Collapse
zargio profile image
PiergiorgioZagaria

I've read the std library implementation and I think MultiArrayList is AOS not SOA. The reason is because in SOA the struct holds lists to each individual component, meanwhile the library stores each component together. Quick example, in a soa I can create an entity with velocity and another with position and they would be separated in different arrays. In multiarraylist I can only create an entity with both velocity And position. I may be wrong and have misread the documentation or have misinterpreted SOA and AOS though

Collapse
kristoff profile image
Loris Cro Author

The interface is meant to give you syntax sugar to make it feel like an AoS list, but internally it’s stored in SoA form. You might think that it’s not SoA because you see a single array of bytes in the MultiArrayList implementation, but that’s the chunk of memory that holds all the per-field arrays.

Thread Thread
zargio profile image
PiergiorgioZagaria

Re-read the documentation and I was wrong on how I thought it worked, I blame the fact that I read it on a phone lol. Anyways thanks for the clarification