The Entity component system (ECS) is a software architectural pattern following a data-oriented architectural style. It is most associated with video game development for the representation of game world objects, and is often characterized by the use of structures of arrays to improve runtime performance. ECS prioritizes composition over inheritance. Every entity is defined not by a type hierarchy, but by the components associated with it. Systems act globally over all entities that have the required components. For example, a food system might iterate through every entity with a relevant component tracking hunger, and act on them to push them a little away from satiation at time intervals. Entities lacking the component like terrain or items would be naturally ignored by the food system. Due to an ambiguity in the English language, an interpretation of the name is that an ECS is a system comprising entities and components. In the 2002 talk at GDC, Scott Bilas compared a C++ object system and his new custom component system. This is consistent with a traditional use of system terms in general systems engineering with Common Lisp Object System and type system as examples. While historically mostly found video game development, the pattern can be useful in other domains, such as in robotics simulators like Gazebo. Recent research has been published that attempts to formalize the ECS pattern as a computational model.
Characteristics ECS combines orthogonal, well-established ideas in general computer science and programming language theory. For example, components can be seen as a mixin idiom in various programming languages. Components are a specialized case under the general delegation approach and meta-object protocol. That is, any complete component object system can be expressed with the templates and empathy model within The Orlando Treaty vision of object-oriented programming.
Entity An entity represents a general-purpose object. In a game engine context, for example, every coarse game object is represented as an entity. Usually, it only consists of a unique ID. Implementations typically use a plain integer for this. Component A component characterizes an entity as possessing a particular aspect, and (the component) holds the data needed to model that aspect. For example, every game object that can take damage might have a Health component associated with its entity. Implementations typically use structs, classes, or associative arrays. System A system is a process that acts on all entities with the desired components. For example, a physics system may query for entities having mass, velocity and position components, iterate over the results, and do physics calculations for each entity using the set of components. The behavior of an entity can be changed at runtime by systems that add, remove or modify components. This eliminates the ambiguity problems of deep and wide inheritance hierarchies often found in object-oriented programming techniques that are difficult to understand, maintain, and extend. Common ECS approaches are highly compatible with, and are often combined with, data-oriented design techniques. Data for all instances of a component are contiguously stored together in physical memory, enabling efficient memory access for systems that operate over many entities.
Formal Model Although ECS originated as an industry practise, recent academic work has proposed formal models of ECS execution. These models generally define an ECS world as:
A set of entities, which provide identity; A collection of component types that represent data; Associations between entities and component instances; Systems that execute computations over entities matching specified component requirements. Under this interpretation, systems do not directly own data. Instead, they operate over subsets of entities selected by component-based queries. ECS programs can therefore be viewed as compositions of transformations over a shared, non-hierarchical data store. Formalizations of ECS have also modeled operations such as entity creation, component addition and removal, system execution, and migration between storage structures as state transitions, providing a basis for reasoning about behavior and correctness.
Relationship to Data-Oriented Design ECS is commonly associated with data-oriented design (DOD), a software design philosophy that emphasizes data layout and memory access patterns as primary design concerns. While ECS and data-oriented design are distinct concepts, many ECS frameworks employ data-oriented storage strategies, such as structure-of-arrays layouts and archetype-based organization, to improve cache utilization and parallel processing efficiency. Consequently, ECS is often regarded as a practical architectural realization of data-oriented design principles.
History In 1963, Ivan Sutherland's Sketchpad stored the visual elements of a drawing using an early form of an ECS. Instead of encapsulating points in different objects (e.g. lines, circles, rectangles) points were stored in a ring buffer, and visual elements were only referencing them. When moving a point, this allowed updating all the shapes and constraints using it. In 1998, Thief: The Dark Project pioneered an ECS. The engine was later used for its sequel, as well as System Shock 2. In 2002, Scott Bilas of Gas Powered Games (Dungeon Siege) gave a seminal talk on ECS. This inspired numerous later well-known implementations. In early January 2007, Mick West who worked on the Tony Hawk series, shared his experiences on the process of ECS adoption at Neversoft. Also in 2007, the team working on Operation Flashpoint: Dragon Rising experimented with ECS designs, including those inspired by Bilas/Dungeon Siege, and Adam Martin later wrote a detailed account of ECS design, including definitions of core terminology and concepts. In particular, Martin's work popularized the ideas of systems as a first-class element, entities as identifiers, components as raw data, and code stored in systems, not in components or entities. In 2015, Apple Inc. introduced GameplayKit, an API framework for iOS, macOS and tvOS game development that includes an implementation of ECS. In October 2018 the company Unity released its megacity demo that utilized a tech stack built on an ECS. Unity's ECS runs on a powerful optimized architecture known as DOTS, which "empowers creators to scale processing in a highly performant manner".
… excerpt ends here. Continue reading the full article.

