After reading Entity Systems are the future of MMOG development, I was fascinated by the conceptual design of Entitiy-Component Systems. This was back in 2014, during our visit to SigFig headquarters in San Francisco. Once the trip ended I started working on a Clojure library.
I had two extra goals on top of achieving basic ECS behavior:
- Allow safe parallelization of systems without extra syntax by the user.
- Take advantage of CPU caches by increased data locality.
First goal was attainable, clecs design supports automatic parallelization by defining the components a system reads and writes with the systems. It is just a matter of writing a scheduler to run the systems respecting the dependencies. Components not defineds as readable or writable cannot be accessed within the system code anyway.
I have researched about how I can achieve the second goal. It turned out to be quite challenging. The difficulty had little to do with Clojure and everything to do with how JVM manages memory. To ensure your component data stored in memory in contiguous manner you would need to resort using native data model. This was the main reason why I did not continue development of clecs.\n\nIf you want to try out a simple ECS in Clojure, clecs is functional.
Links: