4 ms·
There's a third option, an Entity-Component System (ECS). It is common in games but scales well to UIs. Everything in your UI is stored in a flat structure. Ins
by zelly 7y ago
There's a third option, an Entity-Component System (ECS). It is common in games but scales well to UIs. Everything in your UI is stored in a flat structure. Instead of putting a button in a widget 5 layers of nesting deep, you put them all in an Button[] array, and other entities reference a Button by its index. Objects are laid out more like a normalized database table than an OOP tree. Your UI thread is an event loop that iterates over and mutates the widgets. This is extremely fast, cache friendly, easy to reason about, and can scale to the tens of gigabytes (AAA games).
It's funny how the software industry can simultaneously produce games with hundreds of textured 3D models flying around the screen at 60 fps, but if I want to load a big data table of nothing but text in a web browser, the fans start spinning and the scrollbar locks up.