3 ms·
This seems very close to a point an engineer made to me on a game. A case / switch statement was considered very ugly in optimized game code. But in terms of
by georgeecollins 6y ago
This seems very close to a point an engineer made to me on a game. A case / switch statement was considered very ugly in optimized game code. But in terms of performance a polymorphic function was pretty much the same, it just looked cleaner.
- jariel 6y agoIt's a good point, because you remind us that domain matter so much. Outside of gaming and some other places, I don't think people would, for one second, care about the relative performance in this scenario.
- georgeecollins 6y agoAnd people care less in gaming every day. The part of the code that needs to be performant is often in an engine and thus untouched. And optimizing assets is often more important than optimizing code.
- megameter 6y agoGames also have the particular need of being rather database-like in their usage patterns(lots of filtered set iterations), which makes it harder to apply OOP as a whole. OOP likes interfaces, but games are often dealing with aggregates. My observation's that pushing the indirection down to the callsite has the effect of making it easier to view what's happening in terms of concurrency.
- lmm 6y agoProgramming is about writing code that's understandable for humans - otherwise we'd just edit the binaries with a hex editor. A polymorphic function may well compile to the exact same binary as a switch, but it puts the responsibilities in the right place and makes future maintenance much easier.