# Anyone interested in coding a Julia ECS?

**URL:** <https://discourse.julialang.org/t/anyone-interested-in-coding-a-julia-ecs/116587>\
**Category:** Community\
**Created:** [July 3, 2024, 1:46pm UTC](https://discourse.julialang.org/t/anyone-interested-in-coding-a-julia-ecs/116587 "2024-07-03T13:46:54Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![abraemer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/abraemer/32/51403_2.png) [@abraemer](https://discourse.julialang.org/u/abraemer)\
**Post date:** [September 1, 2024, 9:13am UTC](https://discourse.julialang.org/t/anyone-interested-in-coding-a-julia-ecs/116587/10 "2024-09-01T09:13:31Z")

</div>

> [@Tarny\_GG\_Channie](#):
>
> Flecs is an archetypal ECS in C. It stores entities in archetypes. It doesn’t actually compile fused updates like my plan.

I had a brief look and IIUC then `flecs` uses these archetypes as an organizational tool for the data essentially. I does not compile specific versions of functions for every archetype. The linked blog [about the archetypes](https://ajmmertens.medium.com/building-an-ecs-2-archetypes-and-vectorization-fe21690805f9) explicitly mentions _type erasure_ to make things more uniform.

I think that your plan of specializing on every archetype is bound for failure. The main reason being the huge overhead of actually compiling methods (because the compiler is slow). So you’d never want to compile new methods on the fly because that for sure would cause a lag spike. Which means you either need to figure out which archetypes can possible exists (likely impossible) or precompile every variant which is also impossible.  
Additionally, I am not convinced that there is much optimization to be gained from having specialized variants for different trait combinations considering the additional resources it takes. You mention a couple of easy cases where you can save like a few instructions but a few instructions. But I think in general it will be very hard to figure out these optimizations reliably. It is also not quite necessary because it could be done by hand, if a certain combinations arises very frequently. Then the game programmer could profile their game, see that there is an optimization opportunity and introduce a new combined trait (i.e. “PoisonedAndBurning” which gets applied whenever something burning also gets poisoned or vice versa).  
In summary, I think too much specialization does more harm than good. But I totally understand the appeal. From a theoretical perspective it seems so nice and clean just to offload everything to the compiler but in practice it is likely a bad idea.

---

_[View the full topic](https://discourse.julialang.org/t/anyone-interested-in-coding-a-julia-ecs/116587)._
