In order to contrast Shiny's reactive programming model with the imperative programming techniques of traditional UI programming, here's a demonstration of what it looks like when you take Shiny's UI libraries and HTTP/websocket IO model, but remove the reactive programming aspects of it.
The original application code is here. In comparison, this strawman code is:
- More verbose. The server function is more than twice as long.
- Less efficient. During startup, the
updateSelectedData()
function runs twice, andupdateClusters()
andupdatePlot()
each run three times. Only one time each should be needed, which is what happens with the reactive version. - Less maintainable. When a particular input changes, the question of which update functions need to be called, and in what order, is critical for correctness. In non-trivial apps this is very difficult to