3 ms·
So if you need speed, you just have to swallow your OO programmer's pride and put your data in arrays.
by forinti 4mo ago
So if you need speed, you just have to swallow your OO programmer's pride and put your data in arrays.
- theandrewbailey 4mo agoMaybe someone can write an OO language where arrays of structs are automatically stored as structs of arrays. mild /s
- Mizza 4mo agoAre you talking about Zig's MultiArrayList?
- alex7o 4mo agoHe is talking about jai the programing language from Jonathan Blow, which is quite cool but there is no way to access it.
- fp64 4mo agoOdin has some helpers, was one of the more interesting features I found, but never tried. Not sure if you want to consider Odin OO, but well https://odin-lang.org/docs/overview/#soa-struct-arrays https://odin-lang.org/docs/overview/#soa-struct-arrays
- the__alchemist 4mo agoOdin is heavily inspired by the lang he or she is referring to!
- fp64 4mo agoA sibling comment also mentioned Jai. Not sure what I am missing that the original post was explicitly referring to Jai, some inside joke maybe? I am sorry, I only know Odin. Jai is this cult on reddit/discord, right? You get access if you socialize enough or something? Not my thing. Not for a language.
- theandrewbailey 4mo ago(original poster here) I was just throwing out an idea. I had no idea there were already implementations! Because, to my knowledge, conventional popular languages like C/C++/C#/Java/JS/Python don't do that, and automatically doing that (under certain conditions) feels like an easy performance win.
- jevndev 4mo agoFor what it’s worth, a common example of the capabilities of c++26 reflection is exactly this use case. I can’t remember where I first saw it, but this article [0] showcases the technique pretty well. It’s opt-in so not the compiler optimization that you’re imagining but still neat that it’s possible [0] https://brevzin.github.io/c++/2025/05/02/soa/ https://brevzin.github.io/c++/2025/05/02/soa/
- the__alchemist 4mo agoAh. So, the context (Which I read too far into evidently): 1: One of Jai's initial primary marketing points was to address exactly this: SoA performance with AoS ergonomics. 2: Odin is (or was initially) inspired by Jai.
- tlb 4mo agoThere's a package to do this in Julia: https://juliaarrays.github.io/StructArrays.jl/stable/ https://juliaarrays.github.io/StructArrays.jl/stable/
- gryn 4mo agosomething like this https://crates.io/crates/columnar https://crates.io/crates/columnar ?
- bob1029 4mo agoAnd avoid moving said data between physical threads as much as possible. Most of the bottlenecks I see are not due to the organization of data. Unnecessary communication of data is the #1 offender.
- burnt-resistor 4mo agoWorking set and algorithm diagonalization (work independence) FTW. Immutable data structures and copying often helps to avoid cache invalidation penalties.
- jayd16 4mo agoIf you have hot loops with millions of iterations at a time, structure your code accordingly. Its not anti-OO to choose the right data structure for the job.
- kerblang 4mo ago... IF that's your main performance problem. I already know I'm dealing with huge perf issues caused by ORM & lazy-load semantics. I/O abuse is usually going to be so, so much worse than memory/cache issues. Java is mainly used for business information systems, where I/O is king. Plain vanilla memory abuse is also a big one. But my main problem is a mgmt convinced the magic wand of AI will make all sorts of problems dissapear, and it's going to take 5 years for them to realize nope. It's still fun to learn about cache optimization though, esp. when someone makes it reasonably digestible like this. And maybe it also helps people to recognize that OOP is not some great over-arching zen truth of truths.
- chadgpt3 4mo agoIf you had the right language you could use AoS syntax with SoA implementation. I heard Jai was going to have this feature?