SlideShare a Scribd company logo
Entity Component Systems
Yos Riady
yos.io
goo.gl/ECeFOI
A walkthrough of an
ECS implementation in
Elixir
A high-level overview
of Entity Component
Systems
Background
Drawbacks of
traditional OOP /
inheritance style code
ECS Examples Code Next Steps
Real life applications
and examples of ECS
in action
Further learning, future
improvements, and
conclusion
A walkthrough of an
ECS implementation in
Elixir
A high-level overview
of Entity Component
Systems
Background
Drawbacks of
traditional OOP /
inheritance style code
ECS Examples Code Next Steps
Real life applications
and examples of ECS
in action
Further learning, future
improvements, and
conclusion
Animal
hop()
Bunny
swim()
Whale
GameObject
kill()
Killer Whale
Animal
hop()
Bunny
swim()
Whale
hop()
kill()
Killer Bunny
GameObject
kill()
Killer Whale
The challenges with inheritance
The Blob Antipattern
A huge single root class
with a large amount of
functionality.
Subclasses become
overburdened with
unneeded functionality.
Deep Rigid HierarchiesThe Diamond Problem
A walkthrough of an
ECS implementation in
Elixir
A high-level overview
of Entity Component
Systems
Background
Drawbacks of
traditional OOP /
inheritance style code
ECS Examples Code Next Steps
Real life applications
and examples of ECS
in action
Further learning, future
improvements, and
conclusion
Entity Component Systems
● Originally used in game development
○ Tendency to end up with very complex / monolithic classes when using inheritance
○ Thief, Dungeon Siege, Caves of Qud, roguelikes
● Attempts to solve issues due to deep hierarchies
○ Composition over inheritance
● Based on three key abstractions
○ Entity
○ Component
○ System
Entity Component Systems
Component
Components are minimal, reusable
data objects that are plugged into
entities to support some behaviour.
A Component itself has no
behaviour.
A Components tags an entity with a
single quality.
Typically a struct or dictionary.
The “qualities” or “aspects”of
a thing
What qualities might a bunny have?
What components might a bunny have?
Placeable
- int x
- int y
- int z
Huggable
- int fluffiness
Consumable
- float calories
Seeing
- int sight_radius
- boolean night_vision?
Living
- float health
- float age
Hopping
- int hop_distance
Physical
- int height
- int width
- int length
Entities are very simple.
Entities are globally unique IDs.
Entities has no actual data or
behaviour.
Entity are solely the sum of its
components.
A Component gives an Entity its
data.
Entity
An aggregation of Components
The bunny entity
The bunny entity
Placeable
- int x
- int y
- int z
Huggable
- int fluffiness
Consumable
- float calories
Seeing
- int sight_radius
- boolean night_vision?
Living
- float health
- float age
Hopping
- int hop_distance
Physical
- int height
- int width
- int length
The carrot entity
Placeable
- int x
- int y
- int z
Consumable
- float calories
Physical
- int height
- int width
- int length
The ghost entity
Placeable
- int x
- int y
- int z
Spooky
- int spookiness
Seeing
- int sight_radius
- boolean night_vision?
Systems run continuously and
iterate over all Components of its
type.
Systems read and write the state of
Components, resulting in behaviour.
By transitive property, Systems give
Entities behaviour.
Could be a distributed worker pool.
System
Brings entities and components
to life
How does a bunny behave?
Placeable
- x 5
- y -2
- z 10
Living
- age 2.00
Placeable
- x 5
- y -2
- z 0
Living
- age 2.01
“Fall” “Age”
How does a bunny behave?
Placeable
- x 5
- y -2
- z 10
Living
- age 2.00
Placeable
- x 5
- y -2
- z 0
Living
- age 2.01
“Fall” “Age”
Gravity
System
Time
System
Data flow in ECS
Gravity
System
Placeable
- x
- y
- z
Placeable
- x
- y
- z
Placeable
- x
- y
- z
Placeable
- x
- y
- z
Placeable
- x
- y
- z
External
Event Stream
i.e. Time,
Player Input
Acquires behaviour
through changes in
component states.
Reads the continuously
changing state of its
components.
Listens to system
events, updates its state.
Stores data, which gets
updated in response to
events from systems.
Listens to outside
events, publishes
updates to components
Provides the logic that
manipulates the data
encapsulated in
components.
Data flow in ECS
System Component Entity
The spreadsheet analogy for ECS
The spreadsheet analogy for ECS
● Good decoupling, helps divide your monolithic classes
● Clear separation of responsibility
○ Encourages small interfaces
○ Entity.build([PlayerInputComponent])
● Easy reuse and composability
○ Entity.build([FlyingComponent])
○ Entity.build([FlyingComponent, SeeingComponent])
● Straightforward unit testing and mocking
○ Substitute components with mocked components at runtime
● Separates data from functions that act on it
● Runtime object definition
● Parallelizable
Advantages of ECS
● Most people have never even heard of this pattern
● Handling interprocess communication introduces complexity
● Inter-Component communication
○ What happens when a system needs to access multiple components?
● Inter-System communication
○ What happens when two systems need to access the same component?
● Not as concretely defined as other patterns such as MVC
○ There are a multitude of ways to implement ECS
● Instantiation of entities is more involved
○ Who wires up the components?
○ Does the entity itself creates its own components?
○ Does outside code provides the components?
Challenges of ECS
A walkthrough of an
ECS implementation in
Elixir
A high-level overview
of Entity Component
Systems
Background
Drawbacks of
traditional OOP /
inheritance style code
ECS Examples Code Next Steps
Real life applications
and examples of ECS
in action
Further learning, future
improvements, and
conclusion
ECS in the Real World
Entity Component Systems
A walkthrough of an
ECS implementation in
Elixir
A high-level overview
of Entity Component
Systems
Background
Drawbacks of
traditional OOP /
inheritance style code
ECS Examples Code Next Steps
Real life applications
and examples of ECS
in action
Further learning, future
improvements, and
conclusion
Entity Component Systems
in Elixir
What is Elixir?
● Language that compiles to Erlang
● Built on top of the famed Erlang VM (“nine 9s of reliability”)
○ Traditionally used for telecommunications by Ericsson
○ WhatsApp, Facebook Messenger, RabbitMQ, Riak
● Built-in concurrency abstractions (Actor model and OTP)
● A pleasant, modern syntax similar to Ruby
● Immutable and Functional
● Gradual types
● Pattern Matching
● Interop with Erlang
● Metaprogramming through Macros
The Actor Model
● Actors are computational entities that can:
○ Send messages
○ Receive messages
○ Create other actors
● Elixir processes
○ The key abstraction of Elixir’s concurrency model (Demo)
● Erlang OTP
○ Battle-tested patterns for building distributed, fault-tolerance
applications
○ GenServer
Component
A struct containing state attributes
System
A GenServer
Entity
A struct with string id and a collection of
Component PIDs
An ECS implementation in Elixir
Demo
A walkthrough of an
ECS implementation in
Elixir
A high-level overview
of Entity Component
Systems
Background
Drawbacks of
traditional OOP /
inheritance style code
ECS Examples Code Next Steps
Real life applications
and examples of ECS
in action
Further learning, future
improvements, and
conclusion
Next Steps
ECS is an overlooked architectural pattern that overcomes some of the drawbacks
of OOP-style inheritance, and is a great fit for distributed systems.
Branching out into unfamiliar domains is a fruitful source of new ideas and
patterns to write better software.
Entity Component Systems
“
The worst case:
The next generation of programmers grows up only being shown one way of thinking about programming.
So they kind of work on that way of programming—they flesh out all the details, they, you know, kind of solve that particular
model of programming. They’ve figured it all out. And then they teach that to the next generation. So that second generation
then grows up thinking: “Oh, it’s all been figured out. We know what programming is. We know what we’re doing.”
So the most dangerous thought that you can have as a creative person is to think that you know what you’re doing. Because
once you think you know what you’re doing, you stop looking around for other ways of doing things.
If you want to be open or receptive to new ways of thinking, to invent new ways of thinking, I think the first step is you have
to say to yourself, “I don’t know what I’m doing. We as a field don’t know what we’re doing.”
”
Bret Victor, on the Future of Programming
https://vimeo.com/71278954
Next Steps
Thanks
Yos Riady
yos.io

More Related Content

PDF
Game Programming 02 - Component-Based Entity Systems
Nick Pruehs
 
PDF
Style & Design Principles 03 - Component-Based Entity Systems
Nick Pruehs
 
PPTX
UNREAL ENGINE.pptx
Jeyaprabufantacy
 
PDF
ECS (Part 1/3) - Introduction to Data-Oriented Design
Phuong Hoang Vu
 
PPT
Introduction to 2D/3D Graphics
Prabindh Sundareson
 
PDF
Component-Based Entity Systems (Demo)
Nick Pruehs
 
PDF
Unreal Engine 4 Introduction
Sperasoft
 
PPTX
State of transformers in Computer Vision
Deep Kayal
 
Game Programming 02 - Component-Based Entity Systems
Nick Pruehs
 
Style & Design Principles 03 - Component-Based Entity Systems
Nick Pruehs
 
UNREAL ENGINE.pptx
Jeyaprabufantacy
 
ECS (Part 1/3) - Introduction to Data-Oriented Design
Phuong Hoang Vu
 
Introduction to 2D/3D Graphics
Prabindh Sundareson
 
Component-Based Entity Systems (Demo)
Nick Pruehs
 
Unreal Engine 4 Introduction
Sperasoft
 
State of transformers in Computer Vision
Deep Kayal
 

What's hot (20)

PPTX
GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things t...
Gerke Max Preussner
 
PPTX
Decima Engine: Visibility in Horizon Zero Dawn
Guerrilla
 
PPT
Introduction to Unity3D Game Engine
Mohsen Mirhoseini
 
PPTX
The Rendering Pipeline - Challenges & Next Steps
repii
 
PDF
Design your 3d game engine
Daosheng Mu
 
PPTX
Developing and optimizing a procedural game: The Elder Scrolls Blades- Unite ...
Unity Technologies
 
PDF
Unreal Engine Basics 01 - Game Framework
Nick Pruehs
 
PDF
Siggraph2016 - The Devil is in the Details: idTech 666
Tiago Sousa
 
PPTX
Putting the AI Back Into Air: Navigating the Air Space of Horizon Zero Dawn
Guerrilla
 
PDF
김혁, <드래곤 하운드>의 PBR과 레이트레이싱 렌더링 기법, NDC2019
devCAT Studio, NEXON
 
PDF
Graphics Gems from CryENGINE 3 (Siggraph 2013)
Tiago Sousa
 
PDF
The Basics of Unity - The Game Engine
OrisysIndia
 
PPTX
Game object models - Game Engine Architecture
Shawn Presser
 
PPT
How we optimized our Game - Jake & Tess' Finding Monsters Adventure
Felipe Lira
 
PPTX
Player Traversal Mechanics in the Vast World of Horizon Zero Dawn
Guerrilla
 
PDF
1-Introduction (Game Design and Development)
Hafiz Ammar Siddiqui
 
PPT
Fetch execute cycle
cachs_computing
 
PDF
Attention is All You Need (Transformer)
Jeong-Gwan Lee
 
PPTX
Building a turn-based game prototype using ECS - Unite Copenhagen 2019
Unity Technologies
 
PDF
01 - Introduction to Game Mechanics
Hamzah Asyrani Sulaiman
 
GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things t...
Gerke Max Preussner
 
Decima Engine: Visibility in Horizon Zero Dawn
Guerrilla
 
Introduction to Unity3D Game Engine
Mohsen Mirhoseini
 
The Rendering Pipeline - Challenges & Next Steps
repii
 
Design your 3d game engine
Daosheng Mu
 
Developing and optimizing a procedural game: The Elder Scrolls Blades- Unite ...
Unity Technologies
 
Unreal Engine Basics 01 - Game Framework
Nick Pruehs
 
Siggraph2016 - The Devil is in the Details: idTech 666
Tiago Sousa
 
Putting the AI Back Into Air: Navigating the Air Space of Horizon Zero Dawn
Guerrilla
 
김혁, <드래곤 하운드>의 PBR과 레이트레이싱 렌더링 기법, NDC2019
devCAT Studio, NEXON
 
Graphics Gems from CryENGINE 3 (Siggraph 2013)
Tiago Sousa
 
The Basics of Unity - The Game Engine
OrisysIndia
 
Game object models - Game Engine Architecture
Shawn Presser
 
How we optimized our Game - Jake & Tess' Finding Monsters Adventure
Felipe Lira
 
Player Traversal Mechanics in the Vast World of Horizon Zero Dawn
Guerrilla
 
1-Introduction (Game Design and Development)
Hafiz Ammar Siddiqui
 
Fetch execute cycle
cachs_computing
 
Attention is All You Need (Transformer)
Jeong-Gwan Lee
 
Building a turn-based game prototype using ECS - Unite Copenhagen 2019
Unity Technologies
 
01 - Introduction to Game Mechanics
Hamzah Asyrani Sulaiman
 
Ad

Similar to Entity Component Systems (20)

PDF
Entity Component System
Casper van Beuzekom
 
PPTX
GameDev 2017 - Анатолій Ландишев "AAA architecture in Unity3D"
Lviv Startup Club
 
PDF
Entity Component System - a different approach to game and app development
Maxim Zaks
 
PPTX
OGDC 2014: Component based entity system mobile game development
GameLandVN
 
PPTX
We Love Performance! How Tic Toc Games Uses ECS in Mobile Puzzle Games
Unity Technologies
 
PDF
Game Models - A Different Approach
Nick Pruehs
 
PPTX
ECS: Making the Entity Debugger - Unite LA
Unity Technologies
 
PDF
Component-Based and Model-Driven Engineering: what is the difference? A CBSE ...
Ivica Crnkovic
 
PPTX
The Entity Registry System @ Verisign Labs, 2013
eXascale Infolab
 
PDF
Abstractions at Scale – Our Experiences at Twitter
Leonidas Tsementzis
 
PDF
DEFCON 21: EDS: Exploitation Detection System WP
Amr Thabet
 
PPTX
Itacpp.2.la
Carlo Pescio
 
PPTX
Video Games Style Minitheme by Slidesgo.pptx
simarbajaj1234
 
PPT
ece552_23_main_memory_ecc.ppt
BezaAlem2
 
PDF
Practical Multi-language Generative Programming
Schalk Cronjé
 
PDF
Event driven actors - lessons learned
Rick van der Arend
 
PDF
Choking the monolith - The Strangler (Fig) Pattern Applied
TobiasGoeschel
 
DOC
term paper for cbd models
Sukhdeep Singh
 
PPT
designpatterns_blair_upe.ppt
banti43
 
PDF
The Next Mainstream Programming Language: A Game Developer's Perspective
kfrdbs
 
Entity Component System
Casper van Beuzekom
 
GameDev 2017 - Анатолій Ландишев "AAA architecture in Unity3D"
Lviv Startup Club
 
Entity Component System - a different approach to game and app development
Maxim Zaks
 
OGDC 2014: Component based entity system mobile game development
GameLandVN
 
We Love Performance! How Tic Toc Games Uses ECS in Mobile Puzzle Games
Unity Technologies
 
Game Models - A Different Approach
Nick Pruehs
 
ECS: Making the Entity Debugger - Unite LA
Unity Technologies
 
Component-Based and Model-Driven Engineering: what is the difference? A CBSE ...
Ivica Crnkovic
 
The Entity Registry System @ Verisign Labs, 2013
eXascale Infolab
 
Abstractions at Scale – Our Experiences at Twitter
Leonidas Tsementzis
 
DEFCON 21: EDS: Exploitation Detection System WP
Amr Thabet
 
Itacpp.2.la
Carlo Pescio
 
Video Games Style Minitheme by Slidesgo.pptx
simarbajaj1234
 
ece552_23_main_memory_ecc.ppt
BezaAlem2
 
Practical Multi-language Generative Programming
Schalk Cronjé
 
Event driven actors - lessons learned
Rick van der Arend
 
Choking the monolith - The Strangler (Fig) Pattern Applied
TobiasGoeschel
 
term paper for cbd models
Sukhdeep Singh
 
designpatterns_blair_upe.ppt
banti43
 
The Next Mainstream Programming Language: A Game Developer's Perspective
kfrdbs
 
Ad

More from Yos Riady (10)

PDF
Brief introduction to Serverless (2018)
Yos Riady
 
PDF
Type Checking in Javascript with Flow
Yos Riady
 
PDF
Schema-First API Design
Yos Riady
 
PDF
Writing Domain Specific Languages with JSON Schema
Yos Riady
 
PDF
GraphQL in an Age of REST
Yos Riady
 
PDF
Python List Comprehensions
Yos Riady
 
PDF
Ruby on Rails Workshop
Yos Riady
 
PDF
Online Payments and You
Yos Riady
 
PDF
Introduction to React
Yos Riady
 
PPTX
Intro to Web Map APIs
Yos Riady
 
Brief introduction to Serverless (2018)
Yos Riady
 
Type Checking in Javascript with Flow
Yos Riady
 
Schema-First API Design
Yos Riady
 
Writing Domain Specific Languages with JSON Schema
Yos Riady
 
GraphQL in an Age of REST
Yos Riady
 
Python List Comprehensions
Yos Riady
 
Ruby on Rails Workshop
Yos Riady
 
Online Payments and You
Yos Riady
 
Introduction to React
Yos Riady
 
Intro to Web Map APIs
Yos Riady
 

Recently uploaded (20)

PPTX
classification of computer and basic part of digital computer
ravisinghrajpurohit3
 
PDF
49784907924775488180_LRN2959_Data_Pump_23ai.pdf
Abilash868456
 
PPTX
Web Testing.pptx528278vshbuqffqhhqiwnwuq
studylike474
 
PPTX
The-Dawn-of-AI-Reshaping-Our-World.pptxx
parthbhanushali307
 
PDF
ChatPharo: an Open Architecture for Understanding How to Talk Live to LLMs
ESUG
 
PDF
Adobe Illustrator Crack Full Download (Latest Version 2025) Pre-Activated
imang66g
 
PPTX
Presentation about variables and constant.pptx
kr2589474
 
PDF
New Download FL Studio Crack Full Version [Latest 2025]
imang66g
 
PPTX
AI-Ready Handoff: Auto-Summaries & Draft Emails from MQL to Slack in One Flow
bbedford2
 
PDF
vAdobe Premiere Pro 2025 (v25.2.3.004) Crack Pre-Activated Latest
imang66g
 
PDF
Balancing Resource Capacity and Workloads with OnePlan – Avoid Overloading Te...
OnePlan Solutions
 
PPTX
Contractor Management Platform and Software Solution for Compliance
SHEQ Network Limited
 
PDF
Enhancing Healthcare RPM Platforms with Contextual AI Integration
Cadabra Studio
 
PDF
Generating Union types w/ Static Analysis
K. Matthew Dupree
 
PDF
On Software Engineers' Productivity - Beyond Misleading Metrics
Romén Rodríguez-Gil
 
PPTX
ConcordeApp: Engineering Global Impact & Unlocking Billions in Event ROI with AI
chastechaste14
 
PDF
Immersive experiences: what Pharo users do!
ESUG
 
PDF
WatchTraderHub - Watch Dealer software with inventory management and multi-ch...
WatchDealer Pavel
 
PPTX
Maximizing Revenue with Marketo Measure: A Deep Dive into Multi-Touch Attribu...
bbedford2
 
PPTX
Odoo Integration Services by Candidroot Solutions
CandidRoot Solutions Private Limited
 
classification of computer and basic part of digital computer
ravisinghrajpurohit3
 
49784907924775488180_LRN2959_Data_Pump_23ai.pdf
Abilash868456
 
Web Testing.pptx528278vshbuqffqhhqiwnwuq
studylike474
 
The-Dawn-of-AI-Reshaping-Our-World.pptxx
parthbhanushali307
 
ChatPharo: an Open Architecture for Understanding How to Talk Live to LLMs
ESUG
 
Adobe Illustrator Crack Full Download (Latest Version 2025) Pre-Activated
imang66g
 
Presentation about variables and constant.pptx
kr2589474
 
New Download FL Studio Crack Full Version [Latest 2025]
imang66g
 
AI-Ready Handoff: Auto-Summaries & Draft Emails from MQL to Slack in One Flow
bbedford2
 
vAdobe Premiere Pro 2025 (v25.2.3.004) Crack Pre-Activated Latest
imang66g
 
Balancing Resource Capacity and Workloads with OnePlan – Avoid Overloading Te...
OnePlan Solutions
 
Contractor Management Platform and Software Solution for Compliance
SHEQ Network Limited
 
Enhancing Healthcare RPM Platforms with Contextual AI Integration
Cadabra Studio
 
Generating Union types w/ Static Analysis
K. Matthew Dupree
 
On Software Engineers' Productivity - Beyond Misleading Metrics
Romén Rodríguez-Gil
 
ConcordeApp: Engineering Global Impact & Unlocking Billions in Event ROI with AI
chastechaste14
 
Immersive experiences: what Pharo users do!
ESUG
 
WatchTraderHub - Watch Dealer software with inventory management and multi-ch...
WatchDealer Pavel
 
Maximizing Revenue with Marketo Measure: A Deep Dive into Multi-Touch Attribu...
bbedford2
 
Odoo Integration Services by Candidroot Solutions
CandidRoot Solutions Private Limited
 

Entity Component Systems

  • 1. Entity Component Systems Yos Riady yos.io goo.gl/ECeFOI
  • 2. A walkthrough of an ECS implementation in Elixir A high-level overview of Entity Component Systems Background Drawbacks of traditional OOP / inheritance style code ECS Examples Code Next Steps Real life applications and examples of ECS in action Further learning, future improvements, and conclusion
  • 3. A walkthrough of an ECS implementation in Elixir A high-level overview of Entity Component Systems Background Drawbacks of traditional OOP / inheritance style code ECS Examples Code Next Steps Real life applications and examples of ECS in action Further learning, future improvements, and conclusion
  • 6. The challenges with inheritance The Blob Antipattern A huge single root class with a large amount of functionality. Subclasses become overburdened with unneeded functionality. Deep Rigid HierarchiesThe Diamond Problem
  • 7. A walkthrough of an ECS implementation in Elixir A high-level overview of Entity Component Systems Background Drawbacks of traditional OOP / inheritance style code ECS Examples Code Next Steps Real life applications and examples of ECS in action Further learning, future improvements, and conclusion
  • 8. Entity Component Systems ● Originally used in game development ○ Tendency to end up with very complex / monolithic classes when using inheritance ○ Thief, Dungeon Siege, Caves of Qud, roguelikes ● Attempts to solve issues due to deep hierarchies ○ Composition over inheritance ● Based on three key abstractions ○ Entity ○ Component ○ System
  • 10. Component Components are minimal, reusable data objects that are plugged into entities to support some behaviour. A Component itself has no behaviour. A Components tags an entity with a single quality. Typically a struct or dictionary. The “qualities” or “aspects”of a thing
  • 11. What qualities might a bunny have?
  • 12. What components might a bunny have? Placeable - int x - int y - int z Huggable - int fluffiness Consumable - float calories Seeing - int sight_radius - boolean night_vision? Living - float health - float age Hopping - int hop_distance Physical - int height - int width - int length
  • 13. Entities are very simple. Entities are globally unique IDs. Entities has no actual data or behaviour. Entity are solely the sum of its components. A Component gives an Entity its data. Entity An aggregation of Components
  • 15. The bunny entity Placeable - int x - int y - int z Huggable - int fluffiness Consumable - float calories Seeing - int sight_radius - boolean night_vision? Living - float health - float age Hopping - int hop_distance Physical - int height - int width - int length
  • 16. The carrot entity Placeable - int x - int y - int z Consumable - float calories Physical - int height - int width - int length
  • 17. The ghost entity Placeable - int x - int y - int z Spooky - int spookiness Seeing - int sight_radius - boolean night_vision?
  • 18. Systems run continuously and iterate over all Components of its type. Systems read and write the state of Components, resulting in behaviour. By transitive property, Systems give Entities behaviour. Could be a distributed worker pool. System Brings entities and components to life
  • 19. How does a bunny behave? Placeable - x 5 - y -2 - z 10 Living - age 2.00 Placeable - x 5 - y -2 - z 0 Living - age 2.01 “Fall” “Age”
  • 20. How does a bunny behave? Placeable - x 5 - y -2 - z 10 Living - age 2.00 Placeable - x 5 - y -2 - z 0 Living - age 2.01 “Fall” “Age” Gravity System Time System
  • 21. Data flow in ECS Gravity System Placeable - x - y - z Placeable - x - y - z Placeable - x - y - z Placeable - x - y - z Placeable - x - y - z External Event Stream i.e. Time, Player Input
  • 22. Acquires behaviour through changes in component states. Reads the continuously changing state of its components. Listens to system events, updates its state. Stores data, which gets updated in response to events from systems. Listens to outside events, publishes updates to components Provides the logic that manipulates the data encapsulated in components. Data flow in ECS System Component Entity
  • 25. ● Good decoupling, helps divide your monolithic classes ● Clear separation of responsibility ○ Encourages small interfaces ○ Entity.build([PlayerInputComponent]) ● Easy reuse and composability ○ Entity.build([FlyingComponent]) ○ Entity.build([FlyingComponent, SeeingComponent]) ● Straightforward unit testing and mocking ○ Substitute components with mocked components at runtime ● Separates data from functions that act on it ● Runtime object definition ● Parallelizable Advantages of ECS
  • 26. ● Most people have never even heard of this pattern ● Handling interprocess communication introduces complexity ● Inter-Component communication ○ What happens when a system needs to access multiple components? ● Inter-System communication ○ What happens when two systems need to access the same component? ● Not as concretely defined as other patterns such as MVC ○ There are a multitude of ways to implement ECS ● Instantiation of entities is more involved ○ Who wires up the components? ○ Does the entity itself creates its own components? ○ Does outside code provides the components? Challenges of ECS
  • 27. A walkthrough of an ECS implementation in Elixir A high-level overview of Entity Component Systems Background Drawbacks of traditional OOP / inheritance style code ECS Examples Code Next Steps Real life applications and examples of ECS in action Further learning, future improvements, and conclusion
  • 28. ECS in the Real World
  • 30. A walkthrough of an ECS implementation in Elixir A high-level overview of Entity Component Systems Background Drawbacks of traditional OOP / inheritance style code ECS Examples Code Next Steps Real life applications and examples of ECS in action Further learning, future improvements, and conclusion
  • 32. What is Elixir? ● Language that compiles to Erlang ● Built on top of the famed Erlang VM (“nine 9s of reliability”) ○ Traditionally used for telecommunications by Ericsson ○ WhatsApp, Facebook Messenger, RabbitMQ, Riak ● Built-in concurrency abstractions (Actor model and OTP) ● A pleasant, modern syntax similar to Ruby ● Immutable and Functional ● Gradual types ● Pattern Matching ● Interop with Erlang ● Metaprogramming through Macros
  • 33. The Actor Model ● Actors are computational entities that can: ○ Send messages ○ Receive messages ○ Create other actors ● Elixir processes ○ The key abstraction of Elixir’s concurrency model (Demo) ● Erlang OTP ○ Battle-tested patterns for building distributed, fault-tolerance applications ○ GenServer
  • 34. Component A struct containing state attributes System A GenServer Entity A struct with string id and a collection of Component PIDs An ECS implementation in Elixir
  • 35. Demo
  • 36. A walkthrough of an ECS implementation in Elixir A high-level overview of Entity Component Systems Background Drawbacks of traditional OOP / inheritance style code ECS Examples Code Next Steps Real life applications and examples of ECS in action Further learning, future improvements, and conclusion
  • 37. Next Steps ECS is an overlooked architectural pattern that overcomes some of the drawbacks of OOP-style inheritance, and is a great fit for distributed systems. Branching out into unfamiliar domains is a fruitful source of new ideas and patterns to write better software.
  • 39. “ The worst case: The next generation of programmers grows up only being shown one way of thinking about programming. So they kind of work on that way of programming—they flesh out all the details, they, you know, kind of solve that particular model of programming. They’ve figured it all out. And then they teach that to the next generation. So that second generation then grows up thinking: “Oh, it’s all been figured out. We know what programming is. We know what we’re doing.” So the most dangerous thought that you can have as a creative person is to think that you know what you’re doing. Because once you think you know what you’re doing, you stop looking around for other ways of doing things. If you want to be open or receptive to new ways of thinking, to invent new ways of thinking, I think the first step is you have to say to yourself, “I don’t know what I’m doing. We as a field don’t know what we’re doing.” ” Bret Victor, on the Future of Programming https://vimeo.com/71278954 Next Steps