Data locality (sometimes) beats algorithmic complexity 0 ▲ Ankur Sethi 1 hour ago · Tech · hide · 0 comments I've been ECS-curious ever since I learned about it in the Bevy game engine documentation.The ECS architecture predictably improves performance in languages that give you low-level control over memory (C, C++, Rust, Zig, and friends). But how does it fare when used in high-level, dynamic, garbage-collected languages such as JavaScript?This is the question Dan Murphy set out to answer in The Physics of Memory: Is it possible to use an ECS-style architecture in Javascript? And for applicable operations, does that actually do better than objects + V8’s garbage collection? To answer the question, Murphy built a 2D physics simulation of 15,000 balls bouncing around in a box using several different techniques. He found that a JavaScript implementation of the simulation that used ECS outperformed the usual "giant graph of objects" OOP implementation by 24x. He writes: Cache Locality > Algorithmic Complexity: At 15,000 entities, pointer-chasing and unpredictable tree branching cannot compete… No comments yet. Log in to reply on the Fediverse. Comments will appear here.