User interfaces are hard - why?
Every application with an interactive user interface is a distributed system. No need for a server: your app and its user are two actors working with a shared state.
It's not a deep observation but it explains a lot of the unfortunate realities of writing user interface code. Say user performed an action which is going to take 30 seconds and after it's finished the state of the app will be changed. Do you:
- Allow user to interact with the application and deal with the concurrent update problem when the long-running operation finishes?
- Freeze the UI to not deal with concurrent updates but annoy the hell out of the user?
- Create an elaborate locking scheme where the user can continue to use the application unless their actions could conflict with the state update after the long-running operation finishes?
There are no great answers but notice that these are the same stuff you'll consider when designing a distributed system. There's no escape, only tradeoffs:
- If you can make all operations fast, you can get away with blocking the UI while they complete.
- If there's an easy and obviously correct way to combine concurrent updates to the state, you can allow the user to continue using the application.
- If there's a natural locking domain (e.g. per document) you can allow updates to two different documents to be applied concurrently, in any order.