Remix.run Logo
pjmlp 5 days ago

ECS is a part of OOP, hence why languages like Objective-C introduced protocols, while others like C++ and Eiffel went the multiple inheritance route.

Even Smalltalk, post Smalltalk-80 implementations eventually added traits, alongside its single inheritance model.

zaphar 5 days ago | parent [-]

I am not sure what the link between ECS and protocols, traits, and multiple inheritance is? ECS is mostly about memory layout not typed interfaces as far as I know.

pjmlp 5 days ago | parent [-]

Nope, that is the gist that game devs then apply to ECS story.

If you want to go down the rabbit hole, lets start with the first question, how are ECS systems implemented in any random C++ or Rust game code?

user____name 5 days ago | parent [-]

> Nope, that is the gist that game devs then apply to ECS story.

What do you mean? ECS is simply a game programming pattern to implement an entity system.

> If you want to go down the rabbit hole, lets start with the first question, how are ECS systems implemented in any random C++ or Rust game code?

Conversely how would you implement it in a procedural language like C or Pascal? ECS is just a switch in emphasis from an array of structures (entities) to a structure of arrays (systems) paradigm. I fail to see what the Object Oriented paradigm has to do with any of it.

pjmlp 5 days ago | parent [-]

A pattern that relies on OOP constructs like protocols, interfaces, traits, depending on which language is being used.

Arrays and structures mappings isn't ECS, that is Data Oriented Design,

https://en.m.wikipedia.org/wiki/Data-oriented_design

nickitolas 5 days ago | parent [-]

Since you already quoted wikipedia, here's what it says about ECS:

https://en.wikipedia.org/wiki/Entity_component_system

> Entity–component–system (ECS) is a software architectural pattern mostly used in video game development for the representation of game world objects. An ECS comprises entities composed from components of data, with systems which operate on the components.

> 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

> 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 which operate over many entities.

> History > In 1998, Thief: The Dark Project pioneered an ECS.

So, according to wikipedia:

- An entity is typically just a numeric unique id

- Components are typically physically contiguous (i.e an array)

- Their history began with Thief pioneering them in 1998

pjmlp 5 days ago | parent [-]

I was rather expecting code examples, so that we could deconstruct the language primitives being used for the implementation from a CS language semantics point of view.