opened
HalosGhost
username_0
## Prior Art

* #383 
* #2078 
* #2255 
* https://en.wikipedia.org/wiki/AOS_and_SOA

This issue is meant to serve as an issue to address the specific question of how Zig can, should, and (eventually) will provide support for smoothly transitioning between SoA and AoS.

The AoS strategy (an array of structures) is often more natural, and allows simpler code. However, the SoA strategy (where there is only a single structure, embedding arrays) is often more performance friendly for cache layout and SIMD optimization. Unfortunately, in most languages (as in Zig for the moment), switching between these strategies requires large refactoring.

The experimental (and still only privately-available) programming language named [jai](https://inductive.no/jai/) provides for novel tooling to dramatically simplify this transition. Jai offers a special tag that can be placed on structure definitions (``SOA``). When a struct is tagged with ``SOA``, the code is still written as it would be for the AoS strategy, but the memory layout will transparently be SoA. This allows for several pros:

* developers can write code in the most intuitive fashion regardless of which memory layout is more performant for the situation
* this language support offers the refactor as a single-line change rather than refactoring all the related code

The obvious con is that this bit of tooling is very specific (rather than being something more generalized for memory layout). Additionally, it is an extra bit of special syntax rather than something implemented in the language itself.

@tgschultz put together a [short prototype](https://gist.github.com/tgschultz/e7ad60a9d30e6541915cb006b1735adb) of implementing this behavior within Zig which relies on this [helper struct](http://zig.tgschultz.com/pseudo_struct.zig).

This issue can be considered an open question and request for proposal for solution.
Explicit support for AoS/SoA
issue
created
dadhi
username_1
From one of the latest video on Jai, the author said something like an idea of a better option for the problem than SoA / AoS. Though he did not return to this afterward.
comment
created
EleanorNB
username_2
Potentially relevant: #7257
comment
created
andrewrk
username_3
#7920 and #7854 demonstrate two perfectly reasonable ways to implement this in the std lib. There is no language feature needed here.
comment
closed
andrewrk
username_3
issue