What I learned designing a barebones UI engine

Programmer builds their own UI engine and triggers a mini GUI holy war

TLDR: A developer built a simple custom interface system to learn how buttons and layouts really work, then shared the journey. The comment section exploded into a mini culture war over the “right” way to build interfaces, with strong opinions, corrections, and praise for learning by rebuilding from scratch.

A lone developer decided to build their own barebones user interface engine in a game library, just to really understand how all those buttons and menus work under the hood. The article itself is a calm, nerdy breakdown of how they went from a simple list of on‑screen elements to a more sophisticated “family tree” of boxes and buttons. But the real show is in the comments, where people immediately turn it into a battle over how all user interfaces should be built.

One camp storms in shouting that “immediate mode” — a style where you redraw everything every frame — is the one true way. One commenter flat-out declares that keeping long‑term state is “a pain” and that clever tricks like React’s tree‑diffing were just band‑aids for slow web browsers. Another user steps in to school the thread, saying everyone is confused and that this “immediate vs retained” fight is more about how you design the programming interface than what’s really going on under the hood.

Meanwhile, a quieter but wholesome subplot emerges: several devs chime in to praise the author’s decision to reinvent the wheel as a learning exercise, swapping war stories about doing the same in their own game engines. The vibe is half classroom, half bar fight: a mix of encouragement, nitpicking, and "you’re doing it wrong" energy that turns a small UI experiment into a full-on philosophy debate.

Key Points

  • The author built a custom UI framework on top of PyGame to provide a transparent, low-overhead interactive layer for experiments.
  • The initial implementation used a flat list of components with manual pixel positioning, performing hit-testing, updating, and rendering each frame.
  • Manual, flat-list layout proved impractical for general-purpose UIs, motivating a move to higher-level layout semantics.
  • The engine was refactored into a tree-based node hierarchy with layout-only and content-only nodes, using depth-first traversal with `measure()` and `distribute()` methods for layout.
  • The current layout system relies on intrinsic sizing only and lacks constraint support, limiting responsive or fluid layouts; constraint-based enhancements are identified as future work.

Hottest takes

"Immediate mode GUI is the way to go" — cardanome
"Retaining state is a pain and causes bugs" — cardanome
"Lots of confused comments here about immediate vs retained GUIs" — leecommamichael
Made with <3 by @siedrix and @shesho from CDMX. Powered by Forge&Hive.