The compiler will optimize that away
Good article. My own thinking when coding performance is also towards data oriented approaches. For example Bevy in Rust. If stuff needs to be fast, it needs to be in cache. To do that, have everything nicely packed so you only ask for a chunk as often as you need. Then when you need it, it&#x27;s already there.<p>Thing about old fashioned OO is it&#x27;s often fine enough for your run-of-the-mill CRUD app. If you look at the latency chart he provides, there&#x27;s another level to it: going to a database server. If you&#x27;re gonna do that, you&#x27;re not really in the speed game anyway, so why not make it simple? Just write it in the most uncomplicated way the language allows, and that&#x27;s it. Waiting for the DB will take way longer than filtering the ants, forget all the optimizations.<p>Edit:<p>Forgot to mention with ECS, you have a different organizing principle. It can be quite enlightening to work with &quot;systems that operate on data&quot; as opposed to OO where you have the data declared next to the functions that mutate it. It can add clarity for certain problems. Somehow over the years I&#x27;ve found that the animals&#x2F;cars analogies given in OO tutorials are one of the few places that fit well with the model.<p>If you imagine a game that has characters, relationships, items, spells, and so on, it&#x27;s often not that easy to model as encapsulated objects. Does each character have a list of other characters that they have a relationship with? What happens when you want to change the relationship, or a character casts a spell that temporarily changes the relationship? Can easily end up a mess, because it&#x27;s not obvious where such things should live in an OO model.