| ▲ | danabramov 19 hours ago | |||||||||||||||||||||||||||||||||||||
I started with VB6 so I'm sometimes nostalgic for it too but let's not kid ourselves. We might take it for granted but React-like declarative top-down component model (as opposed to imperative UI) was a huge step forward. In particular that there's no difference between initial render or a re-render, and that updating state is enough for everything to propagate down. That's why it went beyond web, and why all modern native UI frameworks have a similar model these days. | ||||||||||||||||||||||||||||||||||||||
| ▲ | josephg 14 hours ago | parent [-] | |||||||||||||||||||||||||||||||||||||
> and why all modern native UI frameworks have a similar model these days. Personally I much rather the approach taken by solidjs / svelte. React’s approach is very inefficient - the entire view tree is rerendered when any change happens. Then they need to diff the new UI state with the old state and do reconciliation. This works well enough for tiny examples, but it’s clunky at scale. And the code to do diffing and reconciliation is insanely complicated. Hello world in react is like 200kb of javascript or something like that. (Smaller gzipped, but the browser still needs to parse it all at startup). And all of that diffing is also pure overhead. It’s simply not needed. The solidjs / react model uses the compiler to figure out how variables changing results in changes to the rendered view tree. Those variables are wrapped up as “observed state”. As a result, you can just update those variables and exactly and only the parts of the UI that need to be changed will be redrawn. No overrendering. No diffing. No virtual Dom and no reconciliation. Hello world in solid or svelte is minuscule - 2kb or something. Unfortunately, swiftui has copied react. And not the superior approach of newer libraries. The rust “Leptos” library implements this same fine grained reactivity, but it’s still married to the web. I’m really hoping someone takes the same idea and ports it to desktop / native UI. | ||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||