Can someone explain to me the benefits of swiftUI/react’s approach over immediate mode graphics? The diffing algo & layer memory seem like overhead when you could render directly to the screen. (JS/DOM Can’t, so there it makes sense)
Conversation
In the case where most of the UI does not change each frame, as is the case in typical application UI, the overhead of diffing is generally lower than typical immediate mode overhead of repainting/emitting-draw-calls.
2
11
But if any visible part of the UI changes, repaint/draw-call still happens via CA anyway, right? So where’s the win?
1
1
I’m assuming the immediate mode approach would only clear/redraw framebuffer when needed, and not every display refresh.
1
1
I see! Yes, you can think of it as a sophisticated version of “when needed.” A typical immediate mode implementation would not have the same kind of tracking. It would need to e.g. compare all of this frame’s draw calls to all of last frame’s.
Yeah—to give a concrete example, consider an animated loading spinner. A retained mode system can know to redraw only the region where the spinner is animating. A fully immediate-mode system would have to redraw the whole screen, since all it knows is "something has updated".
1
2
Ah! This is a very clarifying example. Thank you.


