wait hang on. why does ECS always use bare arrays for holding structs? that makes the bookkeeping way more difficult. wouldn't it be easier to use a simple array based hash table, so that every entity can simply store their data using their ID as the key?

that way iterating over all the values in the table is still fast and cache coherent (it's still just an array) but all the bookkeeping becomes way less complex. no more need for archetypes, just have one hash table per struct and if an entity doesn't have that component, it's as simple as just not adding it to the table

... am i missing something here? O_o i feel like i'm missing something obvious

@eniko No, it really is that simple. In the most "extreme" case you can do away with the concept of entity entirely and just make it an ID and make sure the components belonging to an entity are all tagged with the correct ID.

I've thought of using a sparse array to keep the cache locality and then just when looping over the components check if it's "alive" or not and skipping "dead" components. It'd probably benefit from periodically defragging the array and packing the alive components closer. Keeping an alive and dead list would probably be better than that though.