|
More than React, I'm interested in the question of how to best write UI through code, in general. Even though I'm a fan of React, and use it for practically every web application I build, my biggest and most obvious issue has been that writing UIs through React doesn't feel as natural as, say, writing command line tools in Go, or live/realtime apps in Elixir. Some languages just feel incredibly natural and frictionless for certain things, and nobody has really nailed UIs yet. Swift, JSX/HTML, Svelte, or whatever framework of the week: they all feel like they're working around the problem to some extent. Like at some point in the process, the designers of the language/framework had to compromise and implement some hacky/weird/painful syntax to satisfy project requirements. UI's natural interface is visual, so tools like Figma can serve as an essential part of the solution, but nonetheless, I feel there's something missing. There must be a more intuitive way to represent the visual through code. The current solutions, although I find it hard to describe precisely, are always tantalizingly lacking in one way or another. |
The most reliable and performant UI code I’ve written usually tackles this head on by thinking through all the possibilities of different states the application can be in and how the transition of each state should look. This can very quickly get mind boggling complex.
Systems programming languages seem like they model their problems better because it’s less common to ask a systems programmer for a like button that shows bubbles when you press it. If you model your UI explicitly like a state machine, you can say “no” to the bubbles like every systems programmer says “no” to most features, because you realize the explosion of state will be unmanageable. Or you can use a JavaScript framework and download a bubbles package and wonder why your app is buggy, but have job security.