5 ms·
The SoA transformation makes sense to me and is quite general. The EoA transformation on the other hand feels like a rare special case though it seems perhaps l
by norir 2y ago
The SoA transformation makes sense to me and is quite general. The EoA transformation on the other hand feels like a rare special case though it seems perhaps less rare for the OP.
Either way, these types of optimizations are typically marginal in the context of end to end performance of most programs. It's good to have some knowledge of these kinds of techniques, but most of the time it makes sense to do the thing that is most straightforward to implement and optimize later once the program is already working. Of course if the problem maps neatly onto EoA then that should be preferred in the initial implementation. I though in my 30+ years of programming cannot think of a particular problem that I have solved that would have been enhanced by this.
- AndyKelley 2y agoIt's an alternative to OOP. You can get there via a series of transformations: 1. Start with OOP (heap-allocated objects with shared base structs) 2. Transform to using tagged unions instead 3. Transform to the approach outlined in the OP (I call it the "encoding" approach in this talk: https://vimeo.com/649009599 https://vimeo.com/649009599) It's handy because you get to use an index to refer to an object, and you get serialization benefits. The zig compiler uses this pattern in quite a few places: * https://github.com/ziglang/zig/blob/77c63ac36034db577a9287c54fb6771429a7428f/src/Air.zig https://github.com/ziglang/zig/blob/77c63ac36034db577a9287c5... * https://github.com/ziglang/zig/blob/77c63ac36034db577a9287c54fb6771429a7428f/src/arch/x86_64/Mir.zig https://github.com/ziglang/zig/blob/77c63ac36034db577a9287c5... * https://github.com/ziglang/zig/blob/77c63ac36034db577a9287c54fb6771429a7428f/lib/std/zig/Ast.zig https://github.com/ziglang/zig/blob/77c63ac36034db577a9287c5... * https://github.com/ziglang/zig/blob/77c63ac36034db577a9287c54fb6771429a7428f/src/InternPool.zig https://github.com/ziglang/zig/blob/77c63ac36034db577a9287c5...
- midnightchair 2y agoI'll tell you my experience with Zig. I don't have any. I saw maybe Primagen talking about it and I see your post here. I watched 10 minutes of your vimeo video. I see it has 30k+ stars on github. So now I have to try to understand it in a nutshell. First like any language, I go to indeed.com and put in "Zig" to see if there are any jobs listed which use it. I don't see any. Then I click to https://ziglang.org/ https://ziglang.org/ and it describes Zig as "robust, optimal and reusable". Well that doesn't really say much of anything. I read the example listed, which appears to be a test case, and I wonder how the 'try' mechanism works without a 'catch' Then I go to https://ziglang.org/documentation/master/ https://ziglang.org/documentation/master/ and see that it says: Robust Behavior is correct even for edge cases such as out of memory. I wonder how that works, but there are no links to support this claim. I read a little more then move on. This isn't to say anything one way or another about Zig, its just my 30 minutes of reading about Zig.
- brabel 2y ago> First like any language, I go to indeed.com and put in "Zig" to see if there are any jobs listed which use it. I don't see any. What does that have to do with anything? Zig is still in beta and they explicitly do not recommend that you use it in production yet unless you're ok with frequent breaking changes. Of course there will be very few jobs (though it's being used by a few notable projects already, including Tigerbeetle - authors of the post we're discussing - and Bun, the JS runtime).
- keybored 2y agoWhat a random and untimely user report.
- matdehaast 2y agoI spent 2 seconds clicking on your bio and saw this account was created 4 hours ago. Makes me wonder why you felt the need to create a burner account. This isn't to say anything one way or another about you, its just my 2 second of reading about you.
- marxisttemp 2y agoI’d like to unsubscribe from your blog
- midnightchair 2y agoI disagree. My blog is quite robust and optimal
- tcfhgj 2y agoIsn't performance and memory usage generally enhanced by this? So why not simply default to this instead of defaulting to Interfaces/traits doing dynamic polymorphism? Makes everyone a bit more happy.
- dist1ll 2y ago> I though in my 30+ years of programming cannot think of a particular problem that I have solved that would have been enhanced by this. One example that I frequently deal with that can benefit from this is compiler data structures.