Thoughts on ECS
blog.voxagon.se
blog.voxagon.se
Why not use a RDBMS engine, perhaps specially tuned, to handle your game's data? Joining arbitrary tuples together at runtime as fast as possible has been the fitness function of every commercial RDBMS vendor since inception. Latency incurred by the network hop and disk IO is probably helping to maintain an illusion that these engines are somehow fundamentally incompatible with gaming use cases.
However unfortunately I haven't found any existing DB type solutions that work for the gaming use case, even when looking at in-memory only solutions. Real world business solutions have two major constraints, a) Do a bit of work as fast as possible and b) Do a lot of those bits as fast as possible. They have additional 'pros' where you can always potentially add more hardware to any problem to achieve that throughput.
Gaming uses both of those as well but for the second case it comes at it from c) Always obey the framerate. For 60fps you have 16ms to do everything and of that you might have only 8ms available for code. Even so that might seem a lot, you could for example do 10 billion adds in that time. But throw in a few loops, conditionals and suddenly it means that for a few thousand entities you can do almost no data transformation, copying etc. Everything needs to be in place and ready to access as is.
Existing DB's are about storing data and delivering it, what we need instead is a dynamic memory manager that can move your data around in memory as needed so that elements that are currently being processed together have some advantageous layout and/or are grouped correctly for some process.
The reason OOP-based games have the problems they do is because they're essentially solving an ontological problem taxonomically. This mismatch over-complicates the solution.
1. Slide 12 https://www.gamedevs.org/uploads/data-driven-game-object-sys...
I think this issue is not constrained to OOP-based games. Many business models are not possible to express directly (cleanly) using a heirarchy of OOP types due to concerns around circular dependencies and serialization.
I know you can actually use SQL lite in file mode which would eliminate both of these issues.
That works well, although it does not features parallelism, but still managed to run on a old laptop that can at most run Windows 7.
They admit their proposed solution of statically declaring functionality in an entity has a downside.
> The main limitation is of course that entity types are locked down at compile-time and cannot be changed dynamically.
ECS is used I believe mainly in highly dynamic games.
His proposed alternative to statically hard code functionality in entities is great if you don't have a dynamic functionality which a lot of games dont.
For games like RPGs or space exploration where you have a variety of different entities with a variety of different components you can't really hard code things.
ECS is a great tool in certain situations. Not a great tool in others.
I believe the mentioned Scott Bilas famous talk about composition follows this "EC" model instead of ECS, except that he calls it Game Object instead of Entity.
Just to say that ECS is not the only composition option: Entity with composed behaviors is also an option (and the most traditional one I believe), and it does not have the infamous complexity of "pure" ECS in my opinion.