๐Ÿ‘พ Entity - Component - System (ECS)

Libraries

Compare on NPMTrends and Star History (requires a GH token)

About these numbers and colors

What is ECS?

ECS stands for Entity-Component-System, an architectural pattern widely used in game development that prioritizes performance and composability.

  • Entities are just unique identifiers (IDs) โ€” they have no data or behavior of their own
  • Components are plain data containers attached to entities (e.g., Position, Velocity, Health)
  • Systems are functions that query and process all entities matching a set of components (e.g., a movement system reads Velocity and writes Position every frame)

Why ECS for games?

Performance: Traditional OOP stores object data across scattered heap allocations. ECS stores component data in tightly packed typed arrays, maximizing CPU cache efficiency โ€” especially important when updating thousands of entities per frame.

Composability: Instead of deep inheritance hierarchies, you build behavior by combining components. A Projectile is just an entity with Position, Velocity, and Damage components. Add a HomingTarget component and it becomes a homing missile, no new class required.

Separation of concerns: Systems are pure data processors with no coupling to each other, making individual behaviors easy to test and reuse across different entity types.

ECS vs. OOP

Traditional OOP inheritance (a Player extends Character extends Entity) becomes brittle as game complexity grows. ECS composition handles the same combinations without the diamond inheritance problem. This comparison walks through how the same game entities map to each paradigm.

The Overwatch team gave a famous GDC talk on how ECS shaped their gameโ€™s architecture. Game Engine Entity/Object Models is another great breakdown of different approaches.

Resources