Live data from Hacker News

A Simple Entity Component System (2019)

austinmorlan.com

1–10 of 38 posts

Re: A Simple Entity Component System (2019)

#3
IMO, ECS is a better way of doing OO (even on a non-OO language) than OO languages themselves:

- Avoid the inheritance vs. composition issue

- Entity as a first-class concept (no more Object vs. "Just Value Object", confusion regarding equality of objects, object hash methods)

- System as a first-class concept (not just a consequence of a call stack between multiple inter-dependent objects)

- It serves much of the same purpose of the Flyweight Pattern

- Naturally conductive of functional programming

This particular implementation is interesting, it introduces some additional pieces (Component Manager, System Manager).

Re: A Simple Entity Component System (2019)

#5
That's certainly an interesting way to organize things, though I dislike the reliance on several 'manager/coordinator' classes. (though part of this is my superstition that class names shouldn't end in -er or -or)

The main mechanism seems to be for 'systems' being able to iterate over tuples of 'components' of a specific type for all 'entities'. I can't help but wonder if there isn't a more elegant way of doing this than trying to keep the set of entities for each system up to date. Though I suppose it depends on what you want to optimize.

Re: A Simple Entity Component System (2019)

#7

That's certainly an interesting way to organize things, though I dislike the reliance on several 'manager/coordinator' classes. (though part of this is my superstition that class names shouldn't end in -er or -or) The main mechanism seems to be for 'systems' being able to iterate over tuples of 'components' of a specific type for all 'entities'. I can't help but wonder if there isn't a more elegant way of doing this…

One of the main goals of ECS is to improve the use of the cache and reduce the amount of dereferencing.

An alternative approach, which does not sacrifice the more common OOP style: https://www.doc.ic.ac.uk/%7Escd/ShapesOnwards.pdf

Re: A Simple Entity Component System (2019)

#8

Might be a misread, but this feels a little similar to relational vs columnar databases. Relational databases store a thing's data together; columnar store a type of data together.

A relational DB can store data however it wants, including columnar formats. The interface presented to the programmer (SQL) just abstracts away the details.

ECS are more similar to the relational model than OOP is, and do not necessarily suffer the same 'object–relational impedance mismatch'.

Re: A Simple Entity Component System (2019)

#9
ECS is a one of the possible designs of what we usually call "the gamestate" that is the dynamic structure that holds the game world simulation.

But the origin of ECS is Data Oriented Design, also known as DOD, that emerged as a reaction to the bad properties of OOP.

DOD is more general and IMHO more interesting than ECS.

I have not yet seen a satisfying implementation of ECS, it can be extremely fast compared to OOP approach, but also cumbersome when dealing with dependencies between systems and the ways to handle structural changes.

My take would be : learn the principles, do some benchmark, but do not consider any ECS implementation as gospel, this is not mature yet.

Use the ideas and principles to build a fast simulation in your own way.

Re: A Simple Entity Component System (2019)

#10
I would love to see some exploration of the ECS pattern being used for web development. A couple years ago I wrote an experiment[0] using ECS with Web Components to make a simple calculator, and... it was actually pretty nice. ECS does a great job of flattening nested structures, and would be really curious if this would improve things like prop drilling in React.

0: https://brochington.github.io/ecstatic-doc-site/docs/example...

Post reply on HN