News for hackers. Stuff that matters.
Re:A Thought Experiment: Using the ECS Pattern Outside of Ga... by spankalee on Saturday December 28, 2019 @07:39AM (#21898571)
So many of these kinds of OOP modeling complaints and solved by mixins.
Re:A Thought Experiment: Using the ECS Pattern Outside of Ga... by _carl_jung on Saturday December 28, 2019 @10:36AM (#21899388)
I'd earnestly like to hear the responses to this from the down-voters. I had the same thought and suspect there is a good reason not to use mixins.

One problem off the top of my head is run-time changing of components. An entity that inherits from multiple mixins can't inherit from new mixins (or lose existing ones) at runtime.

Re:A Thought Experiment: Using the ECS Pattern Outside of Ga... by skybrian on Saturday December 28, 2019 @11:31AM (#21899768)
Yes, ECS is usually about runtime changes in behavior. It also uses IDs rather than hard references, like in a database. Deleting an object makes references to it invalid, rather than references keeping objects alive like in a functional or object-oriented object graph.
Re:A Thought Experiment: Using the ECS Pattern Outside of Ga... by spankalee on Saturday December 28, 2019 @02:39PM (#21901188)
But the complaints about OOP in the article are all about the difficulty in modeling orthogonal traits in a single-inheritance hierarchy. That is definitely addressed with mixins.

Nothing in the "Inheritance isn't Always the Best Tool for the Job" section talks about runtime changes in behavior.

Re:A Thought Experiment: Using the ECS Pattern Outside of Ga... by skybrian on Saturday December 28, 2019 @09:25PM (#21903465)
It does touch on it towards the end:

> Most object-oriented languages are designed so that an object's underlying type will be the same for its entire lifetime. This makes things interesting when users want to scale a Circle without maintaining aspect ratio.

Re:A Thought Experiment: Using the ECS Pattern Outside of Ga... by aliswe on Saturday December 28, 2019 @01:48PM (#21900806)
Are you saying that this is different from mixins?
Re:A Thought Experiment: Using the ECS Pattern Outside of Ga... by spankalee on Saturday December 28, 2019 @02:43PM (#21901215)
Absolutely. Single inheritance is a degenerate form of mixin inheritance, where a subclass has a single, fixed superclass.

Mixins simply fix single inheritance so a subclass's parent class is parameterized, and so concrete classes can be composed of several non-related mixins (which will often seem like multiple super-classes).

ECS is a much different and bigger beast. It's a runtime composition pattern, and has almost basically to do with classes or objects.

If you're only complaint about OOP is with single-inheritance, ECS is probably overkill.

Re:A Thought Experiment: Using the ECS Pattern Outside of Ga... by aliswe on Saturday December 28, 2019 @06:40PM (#21902640)
I get that they are different "in action" (I also appreciate that ecs is implemented differently in various places), but conceptually, and for all intents and purposes, they should be regarded as quite similar if I'm not missing something?

Is it the fact that (some implementations of?) mixins' members could collide and conflict with eachother?

Your 3rd paragraph, did you miss "nothing" or perhaps another word?