3 ms·
I don't think memory layout is the sole draw, it's also about incrementally building up programs live.
by tlarkworthy 3y ago
I don't think memory layout is the sole draw, it's also about incrementally building up programs live.
- munificent 3y agoYou don't need ECS for that and it doesn't necessarily buy you much. Composition over inheritance can often accomplish the same goal.
- tlarkworthy 3y agoOf course it buys a lot, you don't blow away program state when you change the program. That's huge for highly stateful programs. Also ecs is a prime example of composition over inheritance
- munificent 3y agoECS is anti-composition. With composition, you say, "This object A has pieces B, C, and D. The way to get to B, C, and D is by going through A." ECS is the exact opposite: "There are components B, C, and D. They may or may not be associated with entity A. In most cases, you shouldn't care because you should be working with B, C, and D directly and not going through A at all."
- tlarkworthy 3y agoI think your latching onto an overly specific definition of composition. The core of composition vs. inheritance is how you add features to a things, and whether that mechanism is decoupled so you can bolt that feature to other things. A feature is a blob of code, as opposed to data, which is a blob of memory. ECS means to add a feature, you write a new system. Its decoupled because you don't have to do anything to anything else in the program. Adding a system (feature/code) affects nothing. To bring it to life on a subset of entities, you add components, which are the data portion. It only affects the joint of those entities that have the component. So again, data can be dynamically added even at runtime without affecting anything else. With inheritance. You need to add a subclass, and restart the program, losing all the data in the process, coz the code is coupled with the data (the definition of a class). This can be annoying for some types of program development.