Live data from Hacker News

A Simple Entity Component System (2019)

austinmorlan.com

21–30 of 38 posts

Re: A Simple Entity Component System (2019)

#21

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 sa…

I've read up on ECS thrice now, (but never used it because I don't do games) and I really WANT to like it, and I feel it does have value in other domains.

But... I realize every time that I forget what an entity, component and system really "is" (i mean to be fair the naming is almost satire of genericness), and the abstraction doesn't stick to my brain in a way that I had hoped. Kinda similar to how monads don't stick, and fades away over time (if you're not doing FP). Usually, this is a red flag for abstractions, but perhaps the material I've read has been poorly written. Does this feeling go away when you're used to it? Does it just feel natural and obvious after a while?

Re: A Simple Entity Component System (2019)

#22

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 sa…

One of the core tenets of OO is encapsulation. ECS rightly treats encapsulation as a bad thing, because data (i.e. entities) should not be encapsulated in the components and systems which operate on them.

Re: A Simple Entity Component System (2019)

#23

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/do…

Fundamentally, UI is nested. The framework has to reflect this and make UI components composable in a bested way or you’ll drive developers crazy.

What I do wonder about is being able to use a data oriented system that does reflect this neat ability. E.g. if the data in an ECS system is viewed as a simplified relational database, what would happen if we replaced it with a simplified graph database?

Re: A Simple Entity Component System (2019)

#24
post #17

The horse is thoroughly out of the barn on this one, but "an Entity Component System" is a misnomer similar to referring to "a Model View Controller". Sometimes it's written as "Entity-Component-System" to clarify that "entities", "components", and "systems" are all concepts within the ECS architecture.

Part of the reason for the confusion is that this is a retcon of sorts. ECS was first described (with a different name) in a postmortem of Dungeon Siege, but as far as I'm aware, the modern usage of "system" was coined by Adam Martin during the development of Operation Flashpoint: Dragon Rising.

There are good technical arguments for making systems into first-class values, of course, but this interpretation will always be in competition with the older one.

Re: A Simple Entity Component System (2019)

#25
post #21

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 sa…

I've read up on ECS thrice now, (but never used it because I don't do games) and I really WANT to like it, and I feel it does have value in other domains. But... I realize every time that I forget what an entity, component and system really "is" (i mean to be fair the naming is almost satire of genericness), and the abstraction doesn't stick to my brain in a way that I had hoped. Kinda similar to how monads don't sti…

You need to use it to have it stick. If you like Rust, spend 30min playing with bevy and you’ll be set.

Re: A Simple Entity Component System (2019)

#26

Something I don't get about ECS: How do you handle interactions between systems, and especially side effects that can affect multiple systems? Because of those, the systems can't really be considered truly independent, can they? Doesn't this cause complexity to go through the roof?

[deleted]

Re: A Simple Entity Component System (2019)

#27

Something I don't get about ECS: How do you handle interactions between systems, and especially side effects that can affect multiple systems? Because of those, the systems can't really be considered truly independent, can they? Doesn't this cause complexity to go through the roof?

Systems communicate via components. They can create empty "marker" components (and remove them again as needed) or, when applicable, put data in shared singleton data structures called "resources."

Re: A Simple Entity Component System (2019)

#28
post #7

Earlier quoted context omitted.

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

Is that really what you get when you put all entity IDs in a set and iterate over those? Sure the component arrays are packed but that's kind of pointless if you're iterating over them in a random order (note that the system proposed here will also gradually destroy the ordering in the packed arrays). Not that I know an easy way to keep a lists of components that ensure that iterating over them is anywhere close to c…

If the system starts ordered and is iterated frequently, and things move (due to deletion) rather less than they are iterated, you can use... bubble sort.

It's basically free to do one stripe of bubble sort while iterating, and for games, you'll iterate everything once or more per frame, but introduce and delete things less.

Re: A Simple Entity Component System (2019)

#29

Something I don't get about ECS: How do you handle interactions between systems, and especially side effects that can affect multiple systems? Because of those, the systems can't really be considered truly independent, can they? Doesn't this cause complexity to go through the roof?

I like to have a message bus to send messages to queues and have systems consuming those queues.

The shared mutable reference to this message bus would be provided to each system requiring it. It's easily achievable in Rust with Bevy, or with Unity DOTS.

When I don't use Unity DOTS and simply good old MonoBehaviours, I call the message handlers as soon as the message is published instead.

Re: A Simple Entity Component System (2019)

#30
post #17

The horse is thoroughly out of the barn on this one, but "an Entity Component System" is a misnomer similar to referring to "a Model View Controller". Sometimes it's written as "Entity-Component-System" to clarify that "entities", "components", and "systems" are all concepts within the ECS architecture.

Part of the reason for the confusion is that this is a retcon of sorts. ECS was first described (with a different name) in a postmortem of Dungeon Siege, but as far as I'm aware, the modern usage of "system" was coined by Adam Martin during the development of Operation Flashpoint: Dragon Rising. There are good technical arguments for making systems into first-class values, of course, but this interpretation will alwa…

Interesting. The reason I find it worth pointing out is that the "entity" and "component" parts are not really that interesting by themselves. You could have an object-oriented "entity-component" system where components encapsulate game logic, for instance. It's the separation of game logic into the separate "systems" that is interesting. That said, the actual implementation of "systems" varies so much that it's not surprising people focus on the "entity" and "component" parts.
Post reply on HN