Why I rewrote my Rust keyboard firmware in Zig: consistency, mastery, and fun
Here&#x27;s another example of the coolness of Zig&#x27;s comptime code execution:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;ziglang&#x2F;zig&#x2F;commit&#x2F;0808d98e10c5fea27cebf912c6296b760c2b837b" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;ziglang&#x2F;zig&#x2F;commit&#x2F;0808d98e10c5fea27cebf9...</a><p>That&#x27;s a generic container class (similar to vector in C++ or List in C#). But! With a twist!<p>It stores structs in &quot;column major&quot; order in memory (e.g., if a struct had two fields A and B, then in-memory layout would be A...AB...B), and you can idiomatically and efficiently get a a slice of the values of each column.<p>I.e., it&#x27;s a datastructure that automatically applies the struct-of-arrays optimization:<p><a href="https:&#x2F;&#x2F;en.m.wikipedia.org&#x2F;wiki&#x2F;AoS_and_SoA#Structure_of_Arrays" rel="nofollow">https:&#x2F;&#x2F;en.m.wikipedia.org&#x2F;wiki&#x2F;AoS_and_SoA#Structure_of_Arr...</a><p>And the code to do it is straightforward, normal Zig.<p>Pretty awesome stuff!