SlideShare ist ein Scribd-Unternehmen logo
1 von 40
Downloaden Sie, um offline zu lesen
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
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.
“
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

Weitere ähnliche Inhalte

Was ist angesagt?

Unreal_GameAbilitySystem.pptx
Unreal_GameAbilitySystem.pptxUnreal_GameAbilitySystem.pptx
Unreal_GameAbilitySystem.pptxTonyCms
 
AAA게임_UI_최적화_및_빌드하기.pptx
AAA게임_UI_최적화_및_빌드하기.pptxAAA게임_UI_최적화_및_빌드하기.pptx
AAA게임_UI_최적화_및_빌드하기.pptxTonyCms
 
【Unite 2018 Tokyo】そろそろ楽がしたい!新アセットバンドルワークフロー&リソースマネージャー詳細解説
【Unite 2018 Tokyo】そろそろ楽がしたい!新アセットバンドルワークフロー&リソースマネージャー詳細解説【Unite 2018 Tokyo】そろそろ楽がしたい!新アセットバンドルワークフロー&リソースマネージャー詳細解説
【Unite 2018 Tokyo】そろそろ楽がしたい!新アセットバンドルワークフロー&リソースマネージャー詳細解説Unity Technologies Japan K.K.
 
Forts and Fights Scaling Performance on Unreal Engine*
Forts and Fights Scaling Performance on Unreal Engine*Forts and Fights Scaling Performance on Unreal Engine*
Forts and Fights Scaling Performance on Unreal Engine*Intel® Software
 
조정훈, 게임 프로그래머를 위한 클래스 설계, NDC2012
조정훈, 게임 프로그래머를 위한 클래스 설계, NDC2012조정훈, 게임 프로그래머를 위한 클래스 설계, NDC2012
조정훈, 게임 프로그래머를 위한 클래스 설계, NDC2012devCAT Studio, NEXON
 
[NDC_16] 캐릭터 한 달에 하나씩 업데이트 하기 : '최강의 군단' 스킬 개발 툴 포스트 모템과 차기작 '건파이트 맨션' 툴 프리뷰
[NDC_16] 캐릭터 한 달에 하나씩 업데이트 하기 : '최강의 군단' 스킬 개발 툴 포스트 모템과 차기작 '건파이트 맨션' 툴 프리뷰[NDC_16] 캐릭터 한 달에 하나씩 업데이트 하기 : '최강의 군단' 스킬 개발 툴 포스트 모템과 차기작 '건파이트 맨션' 툴 프리뷰
[NDC_16] 캐릭터 한 달에 하나씩 업데이트 하기 : '최강의 군단' 스킬 개발 툴 포스트 모템과 차기작 '건파이트 맨션' 툴 프리뷰승민 백
 
레퍼런스만 알면 언리얼 엔진이 제대로 보인다
레퍼런스만 알면 언리얼 엔진이 제대로 보인다레퍼런스만 알면 언리얼 엔진이 제대로 보인다
레퍼런스만 알면 언리얼 엔진이 제대로 보인다Lee Dustin
 
『FINAL FANTASY VII REMAKE』におけるプロファイリングと最適化事例 UNREAL FEST EXTREME 2021 SUMMER
『FINAL FANTASY VII REMAKE』におけるプロファイリングと最適化事例 UNREAL FEST EXTREME 2021 SUMMER『FINAL FANTASY VII REMAKE』におけるプロファイリングと最適化事例 UNREAL FEST EXTREME 2021 SUMMER
『FINAL FANTASY VII REMAKE』におけるプロファイリングと最適化事例 UNREAL FEST EXTREME 2021 SUMMERエピック・ゲームズ・ジャパン Epic Games Japan
 
GameInstance에 대해서 알아보자
GameInstance에 대해서 알아보자GameInstance에 대해서 알아보자
GameInstance에 대해서 알아보자TonyCms
 
UE4 コリジョン検証 -HitとOverlapイベントが発生する条件について-
UE4 コリジョン検証 -HitとOverlapイベントが発生する条件について-UE4 コリジョン検証 -HitとOverlapイベントが発生する条件について-
UE4 コリジョン検証 -HitとOverlapイベントが発生する条件について-Tatsuya Iwama
 
이승재, 사례로 배우는 디스어셈블리 디버깅, NDC2014
이승재, 사례로 배우는 디스어셈블리 디버깅, NDC2014이승재, 사례로 배우는 디스어셈블리 디버깅, NDC2014
이승재, 사례로 배우는 디스어셈블리 디버깅, NDC2014devCAT Studio, NEXON
 
Unreal Engine Basics 01 - Game Framework
Unreal Engine Basics 01 - Game FrameworkUnreal Engine Basics 01 - Game Framework
Unreal Engine Basics 01 - Game FrameworkNick Pruehs
 

Was ist angesagt? (20)

Unreal_GameAbilitySystem.pptx
Unreal_GameAbilitySystem.pptxUnreal_GameAbilitySystem.pptx
Unreal_GameAbilitySystem.pptx
 
AAA게임_UI_최적화_및_빌드하기.pptx
AAA게임_UI_최적화_및_빌드하기.pptxAAA게임_UI_최적화_및_빌드하기.pptx
AAA게임_UI_최적화_및_빌드하기.pptx
 
Localization feature of ue4
Localization feature of ue4Localization feature of ue4
Localization feature of ue4
 
Pig & Kyoto -Let's be the God of Destruction in UE4-
Pig & Kyoto -Let's be the God of Destruction in UE4-Pig & Kyoto -Let's be the God of Destruction in UE4-
Pig & Kyoto -Let's be the God of Destruction in UE4-
 
【Unite 2018 Tokyo】そろそろ楽がしたい!新アセットバンドルワークフロー&リソースマネージャー詳細解説
【Unite 2018 Tokyo】そろそろ楽がしたい!新アセットバンドルワークフロー&リソースマネージャー詳細解説【Unite 2018 Tokyo】そろそろ楽がしたい!新アセットバンドルワークフロー&リソースマネージャー詳細解説
【Unite 2018 Tokyo】そろそろ楽がしたい!新アセットバンドルワークフロー&リソースマネージャー詳細解説
 
Forts and Fights Scaling Performance on Unreal Engine*
Forts and Fights Scaling Performance on Unreal Engine*Forts and Fights Scaling Performance on Unreal Engine*
Forts and Fights Scaling Performance on Unreal Engine*
 
조정훈, 게임 프로그래머를 위한 클래스 설계, NDC2012
조정훈, 게임 프로그래머를 위한 클래스 설계, NDC2012조정훈, 게임 프로그래머를 위한 클래스 설계, NDC2012
조정훈, 게임 프로그래머를 위한 클래스 설계, NDC2012
 
[NDC_16] 캐릭터 한 달에 하나씩 업데이트 하기 : '최강의 군단' 스킬 개발 툴 포스트 모템과 차기작 '건파이트 맨션' 툴 프리뷰
[NDC_16] 캐릭터 한 달에 하나씩 업데이트 하기 : '최강의 군단' 스킬 개발 툴 포스트 모템과 차기작 '건파이트 맨션' 툴 프리뷰[NDC_16] 캐릭터 한 달에 하나씩 업데이트 하기 : '최강의 군단' 스킬 개발 툴 포스트 모템과 차기작 '건파이트 맨션' 툴 프리뷰
[NDC_16] 캐릭터 한 달에 하나씩 업데이트 하기 : '최강의 군단' 스킬 개발 툴 포스트 모템과 차기작 '건파이트 맨션' 툴 프리뷰
 
猫でも分かるUE4.22から入ったSubsystem
猫でも分かるUE4.22から入ったSubsystem 猫でも分かるUE4.22から入ったSubsystem
猫でも分かるUE4.22から入ったSubsystem
 
猫でも分かる UE4の新しいサンプル「Action RPG」について
猫でも分かる UE4の新しいサンプル「Action RPG」について猫でも分かる UE4の新しいサンプル「Action RPG」について
猫でも分かる UE4の新しいサンプル「Action RPG」について
 
레퍼런스만 알면 언리얼 엔진이 제대로 보인다
레퍼런스만 알면 언리얼 엔진이 제대로 보인다레퍼런스만 알면 언리얼 엔진이 제대로 보인다
레퍼런스만 알면 언리얼 엔진이 제대로 보인다
 
『FINAL FANTASY VII REMAKE』におけるプロファイリングと最適化事例 UNREAL FEST EXTREME 2021 SUMMER
『FINAL FANTASY VII REMAKE』におけるプロファイリングと最適化事例 UNREAL FEST EXTREME 2021 SUMMER『FINAL FANTASY VII REMAKE』におけるプロファイリングと最適化事例 UNREAL FEST EXTREME 2021 SUMMER
『FINAL FANTASY VII REMAKE』におけるプロファイリングと最適化事例 UNREAL FEST EXTREME 2021 SUMMER
 
UE4.14で広がるVRの可能性
UE4.14で広がるVRの可能性UE4.14で広がるVRの可能性
UE4.14で広がるVRの可能性
 
GameInstance에 대해서 알아보자
GameInstance에 대해서 알아보자GameInstance에 대해서 알아보자
GameInstance에 대해서 알아보자
 
UE4 コリジョン検証 -HitとOverlapイベントが発生する条件について-
UE4 コリジョン検証 -HitとOverlapイベントが発生する条件について-UE4 コリジョン検証 -HitとOverlapイベントが発生する条件について-
UE4 コリジョン検証 -HitとOverlapイベントが発生する条件について-
 
이승재, 사례로 배우는 디스어셈블리 디버깅, NDC2014
이승재, 사례로 배우는 디스어셈블리 디버깅, NDC2014이승재, 사례로 배우는 디스어셈블리 디버깅, NDC2014
이승재, 사례로 배우는 디스어셈블리 디버깅, NDC2014
 
UE4におけるエフェクトの基本戦略事例 前半
UE4におけるエフェクトの基本戦略事例  前半UE4におけるエフェクトの基本戦略事例  前半
UE4におけるエフェクトの基本戦略事例 前半
 
[GTMF2019]Unreal Engine 4の2019年上半期 アップデート情報まとめ
[GTMF2019]Unreal Engine 4の2019年上半期 アップデート情報まとめ[GTMF2019]Unreal Engine 4の2019年上半期 アップデート情報まとめ
[GTMF2019]Unreal Engine 4の2019年上半期 アップデート情報まとめ
 
Unreal Engine Basics 01 - Game Framework
Unreal Engine Basics 01 - Game FrameworkUnreal Engine Basics 01 - Game Framework
Unreal Engine Basics 01 - Game Framework
 
UE4でマルチプレイヤーゲームを作ろう
UE4でマルチプレイヤーゲームを作ろうUE4でマルチプレイヤーゲームを作ろう
UE4でマルチプレイヤーゲームを作ろう
 

Ähnlich wie Entity Component Systems

Yann le cun
Yann le cunYann le cun
Yann le cunYandex
 
Dev Environments: The Next Generation
Dev Environments: The Next GenerationDev Environments: The Next Generation
Dev Environments: The Next GenerationTravis Thieman
 
MiniOS: an instructional platform for teaching operating systems labs
MiniOS: an instructional platform for teaching operating systems labsMiniOS: an instructional platform for teaching operating systems labs
MiniOS: an instructional platform for teaching operating systems labsRafael Roman Otero
 
Xcore meets IncQuery: How the New Generation of DSLs are Made
Xcore meets IncQuery: How the New Generation of DSLs are MadeXcore meets IncQuery: How the New Generation of DSLs are Made
Xcore meets IncQuery: How the New Generation of DSLs are MadeIstvan Rath
 
Pharo: A Reflective System
Pharo: A Reflective SystemPharo: A Reflective System
Pharo: A Reflective SystemPharo
 
Un actor (model) per amico - Alessandro Melchiori - Codemotion Milan 2016
Un actor (model) per amico - Alessandro Melchiori - Codemotion Milan 2016Un actor (model) per amico - Alessandro Melchiori - Codemotion Milan 2016
Un actor (model) per amico - Alessandro Melchiori - Codemotion Milan 2016Codemotion
 
Parallelizing Conqueror's Blade
Parallelizing Conqueror's BladeParallelizing Conqueror's Blade
Parallelizing Conqueror's BladeIntel® Software
 
Robotlegs AS3 from Flash and the City 2010
Robotlegs AS3 from Flash and the City 2010Robotlegs AS3 from Flash and the City 2010
Robotlegs AS3 from Flash and the City 2010Joel Hooks
 
Lean Engineering: Engineering for Learning & Experimentation in the Enterpris...
Lean Engineering: Engineering for Learning & Experimentation in the Enterpris...Lean Engineering: Engineering for Learning & Experimentation in the Enterpris...
Lean Engineering: Engineering for Learning & Experimentation in the Enterpris...Rosenfeld Media
 
Brains, Data, and Machine Intelligence (2014 04 14 London Meetup)
Brains, Data, and Machine Intelligence (2014 04 14 London Meetup)Brains, Data, and Machine Intelligence (2014 04 14 London Meetup)
Brains, Data, and Machine Intelligence (2014 04 14 London Meetup)Numenta
 
Xtext beyond the defaults - how to tackle performance problems
Xtext beyond the defaults -  how to tackle performance problemsXtext beyond the defaults -  how to tackle performance problems
Xtext beyond the defaults - how to tackle performance problemsHolger Schill
 
Evolve Your Code
Evolve Your CodeEvolve Your Code
Evolve Your CodeRookieOne
 
Domain oriented development
Domain oriented developmentDomain oriented development
Domain oriented developmentrajmundr
 
Reactive applications and Akka intro used in the Madrid Scala Meetup
Reactive applications and Akka intro used in the Madrid Scala MeetupReactive applications and Akka intro used in the Madrid Scala Meetup
Reactive applications and Akka intro used in the Madrid Scala MeetupMiguel Pastor
 
Microservices: Redundancy = Maintainability! (Eberhard Wolff Technology Stream)
Microservices: Redundancy = Maintainability! (Eberhard Wolff Technology Stream)Microservices: Redundancy = Maintainability! (Eberhard Wolff Technology Stream)
Microservices: Redundancy = Maintainability! (Eberhard Wolff Technology Stream)IT Arena
 
Demystifying NLP Transformers: Understanding the Power and Architecture behin...
Demystifying NLP Transformers: Understanding the Power and Architecture behin...Demystifying NLP Transformers: Understanding the Power and Architecture behin...
Demystifying NLP Transformers: Understanding the Power and Architecture behin...NILESH VERMA
 
Pharo: A Reflective System
Pharo: A Reflective SystemPharo: A Reflective System
Pharo: A Reflective SystemMarcus Denker
 
Developing Actors in Azure with .net
Developing Actors in Azure with .netDeveloping Actors in Azure with .net
Developing Actors in Azure with .netMarco Parenzan
 

Ähnlich wie Entity Component Systems (20)

Yann le cun
Yann le cunYann le cun
Yann le cun
 
Dev Environments: The Next Generation
Dev Environments: The Next GenerationDev Environments: The Next Generation
Dev Environments: The Next Generation
 
MiniOS: an instructional platform for teaching operating systems labs
MiniOS: an instructional platform for teaching operating systems labsMiniOS: an instructional platform for teaching operating systems labs
MiniOS: an instructional platform for teaching operating systems labs
 
Xcore meets IncQuery: How the New Generation of DSLs are Made
Xcore meets IncQuery: How the New Generation of DSLs are MadeXcore meets IncQuery: How the New Generation of DSLs are Made
Xcore meets IncQuery: How the New Generation of DSLs are Made
 
Pharo: A Reflective System
Pharo: A Reflective SystemPharo: A Reflective System
Pharo: A Reflective System
 
Un actor (model) per amico - Alessandro Melchiori - Codemotion Milan 2016
Un actor (model) per amico - Alessandro Melchiori - Codemotion Milan 2016Un actor (model) per amico - Alessandro Melchiori - Codemotion Milan 2016
Un actor (model) per amico - Alessandro Melchiori - Codemotion Milan 2016
 
lecun-01.ppt
lecun-01.pptlecun-01.ppt
lecun-01.ppt
 
Parallelizing Conqueror's Blade
Parallelizing Conqueror's BladeParallelizing Conqueror's Blade
Parallelizing Conqueror's Blade
 
Robotlegs AS3 from Flash and the City 2010
Robotlegs AS3 from Flash and the City 2010Robotlegs AS3 from Flash and the City 2010
Robotlegs AS3 from Flash and the City 2010
 
Lean Engineering: Engineering for Learning & Experimentation in the Enterpris...
Lean Engineering: Engineering for Learning & Experimentation in the Enterpris...Lean Engineering: Engineering for Learning & Experimentation in the Enterpris...
Lean Engineering: Engineering for Learning & Experimentation in the Enterpris...
 
Brains, Data, and Machine Intelligence (2014 04 14 London Meetup)
Brains, Data, and Machine Intelligence (2014 04 14 London Meetup)Brains, Data, and Machine Intelligence (2014 04 14 London Meetup)
Brains, Data, and Machine Intelligence (2014 04 14 London Meetup)
 
Xtext beyond the defaults - how to tackle performance problems
Xtext beyond the defaults -  how to tackle performance problemsXtext beyond the defaults -  how to tackle performance problems
Xtext beyond the defaults - how to tackle performance problems
 
Evolve Your Code
Evolve Your CodeEvolve Your Code
Evolve Your Code
 
Domain oriented development
Domain oriented developmentDomain oriented development
Domain oriented development
 
Reactive applications and Akka intro used in the Madrid Scala Meetup
Reactive applications and Akka intro used in the Madrid Scala MeetupReactive applications and Akka intro used in the Madrid Scala Meetup
Reactive applications and Akka intro used in the Madrid Scala Meetup
 
Microservices: Redundancy = Maintainability! (Eberhard Wolff Technology Stream)
Microservices: Redundancy = Maintainability! (Eberhard Wolff Technology Stream)Microservices: Redundancy = Maintainability! (Eberhard Wolff Technology Stream)
Microservices: Redundancy = Maintainability! (Eberhard Wolff Technology Stream)
 
Demystifying NLP Transformers: Understanding the Power and Architecture behin...
Demystifying NLP Transformers: Understanding the Power and Architecture behin...Demystifying NLP Transformers: Understanding the Power and Architecture behin...
Demystifying NLP Transformers: Understanding the Power and Architecture behin...
 
Pharo: A Reflective System
Pharo: A Reflective SystemPharo: A Reflective System
Pharo: A Reflective System
 
The State of Wicket
The State of WicketThe State of Wicket
The State of Wicket
 
Developing Actors in Azure with .net
Developing Actors in Azure with .netDeveloping Actors in Azure with .net
Developing Actors in Azure with .net
 

Mehr von Yos Riady

Brief introduction to Serverless (2018)
Brief introduction to Serverless (2018)Brief introduction to Serverless (2018)
Brief introduction to Serverless (2018)Yos Riady
 
Type Checking in Javascript with Flow
Type Checking in Javascript with FlowType Checking in Javascript with Flow
Type Checking in Javascript with FlowYos Riady
 
Schema-First API Design
Schema-First API DesignSchema-First API Design
Schema-First API DesignYos Riady
 
Writing Domain Specific Languages with JSON Schema
Writing Domain Specific Languages with JSON SchemaWriting Domain Specific Languages with JSON Schema
Writing Domain Specific Languages with JSON SchemaYos Riady
 
GraphQL in an Age of REST
GraphQL in an Age of RESTGraphQL in an Age of REST
GraphQL in an Age of RESTYos Riady
 
Python List Comprehensions
Python List ComprehensionsPython List Comprehensions
Python List ComprehensionsYos Riady
 
Ruby on Rails Workshop
Ruby on Rails WorkshopRuby on Rails Workshop
Ruby on Rails WorkshopYos Riady
 
Online Payments and You
Online Payments and YouOnline Payments and You
Online Payments and YouYos Riady
 
Introduction to React
Introduction to ReactIntroduction to React
Introduction to ReactYos Riady
 
Intro to Web Map APIs
Intro to Web Map APIsIntro to Web Map APIs
Intro to Web Map APIsYos Riady
 

Mehr von Yos Riady (10)

Brief introduction to Serverless (2018)
Brief introduction to Serverless (2018)Brief introduction to Serverless (2018)
Brief introduction to Serverless (2018)
 
Type Checking in Javascript with Flow
Type Checking in Javascript with FlowType Checking in Javascript with Flow
Type Checking in Javascript with Flow
 
Schema-First API Design
Schema-First API DesignSchema-First API Design
Schema-First API Design
 
Writing Domain Specific Languages with JSON Schema
Writing Domain Specific Languages with JSON SchemaWriting Domain Specific Languages with JSON Schema
Writing Domain Specific Languages with JSON Schema
 
GraphQL in an Age of REST
GraphQL in an Age of RESTGraphQL in an Age of REST
GraphQL in an Age of REST
 
Python List Comprehensions
Python List ComprehensionsPython List Comprehensions
Python List Comprehensions
 
Ruby on Rails Workshop
Ruby on Rails WorkshopRuby on Rails Workshop
Ruby on Rails Workshop
 
Online Payments and You
Online Payments and YouOnline Payments and You
Online Payments and You
 
Introduction to React
Introduction to ReactIntroduction to React
Introduction to React
 
Intro to Web Map APIs
Intro to Web Map APIsIntro to Web Map APIs
Intro to Web Map APIs
 

Kürzlich hochgeladen

Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesVictorSzoltysek
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionOnePlan Solutions
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfonteinmasabamasaba
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech studentsHimanshiGarg82
 
ManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide DeckManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide DeckManageIQ
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfproinshot.com
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrandmasabamasaba
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...kalichargn70th171
 
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456KiaraTiradoMicha
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park masabamasaba
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdfPearlKirahMaeRagusta1
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 

Kürzlich hochgeladen (20)

Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
ManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide DeckManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide Deck
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 

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
  • 29.
  • 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.
  • 38.
  • 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