AIFeed

Optimistic Update vs. Immediate Intent

Original text(via Lobsters)

Optimistic update Bad

The UI assumes the operation will succeed and shows the result before it’s saved.

Immediate intent Good

The UI never assumes; it always tells you what’s actually going on.

Immediate intent can save lives!

Picture a cloud-based medication tracker. You take your morning pill 💊, tap Track Pill and close the app. That evening, you open it again, and... didn’t I install this app to help me remember?!

Unlike optimistic updates, immediate intent doesn’t give you a false sense of safety.

  • Orders that silently went nowhere. The VA’s new health record system failed to deliver over 11,000 clinical orders and never told the clinicians who sent them. 149 patients were harmed, including a veteran at risk of suicide whose psychiatric follow-up was lost. VA OIG, 2022
  • A pump that forgot the last dose. After certain errors, the MiniMed 670G insulin pump showed 0.0 units of active insulin right after a large dose. A user who dosed again risked severe hypoglycemia. FDA recall, 2021
  • Insulin skipped without a word. A bug in the Tandem Mobi Android app could drop part of an insulin dose without a distinct alert. FDA recall, 2026

Optimistic updates save waste time.

Once an app has lied to you, you stop trusting it. So you double-check everything yourself.

Okay, okay... these numbers are not empirically measured, yet I bet you will agree that software you can trust saves you time.

  • One visible error is enough. People avoid an algorithm after seeing it make a mistake, even when it outperforms humans. Dietvorst et al., 2015
  • Seeing failures makes people verify. Operators who saw an automated aid fail checked its advice more carefully afterwards. Bahner et al., 2008
  • Checking breeds doubt. The more people re-checked, the less they trusted their own memory, even though it stayed just as accurate. van den Hout & Kindt, 2003

Don’t pretend to be fast. Be fast.

Under about 100 ms, a response feels instant, so you can even skip the pending state when the response arrives that fast. Get there for real, with a faster backend and servers close to your users.

Optimistic updates hide latency. Fast infrastructure removes it. If you can’t be fast, at least be honest.

  • Find where the time goes. The standard reference on profiling and tuning servers. Brendan Gregg, Systems Performance
  • Speed up the database. A slow backend is often waiting on slow queries. A free guide to indexing them. Markus Winand, Use The Index, Luke!
  • Know your numbers. How long a memory read, a disk seek or a round trip across the world takes. Latency numbers every programmer should know
  • Fix the slowest responses. When a request touches many servers, rare slow ones slow down most requests. Dean & Barroso, The Tail at Scale
  • You can’t beat the speed of light. Why distance sets a floor on latency, however fast your code is. Ilya Grigorik, High Performance Browser Networking
  • See how far away your users are. Real round-trip times between cities around the world. WonderNetwork global pings
  • Meet users at the edge. Servers near users set up connections faster, even for requests that go on to yours. Ilya Grigorik, Early Termination
  • Bring the data along. Replication and its trade-offs, for when the database has to be close too. Martin Kleppmann, Designing Data-Intensive Applications

We don’t have to block interaction.

There’s no need to freeze the board to remain honest: just show the intent on the card and keep the position. If it fails, return the card to its last confirmed position and explain what happened.

  • Cancel what’s outdated. Abort an in-flight request when the user moves the card again. MDN, AbortController
  • Ignore late answers. Why an old response can overwrite a newer one, and the simple flag that prevents it. React docs, Fetching data
  • Make retries safe. Idempotency keys, from the API that made them popular. Stripe, Designing APIs with idempotency
  • Send where, not how. “Put it 2nd in In Progress” is safe to repeat; “move it one column right” isn’t. MDN, Idempotent
  • Don’t overwrite newer changes. ETag and If-Match turn a silent clash into a clear error. MDN, HTTP conditional requests
  • Animate layout changes. The technique behind the sliding cards, fast even on slow devices. Paul Lewis, FLIP Your Animations
  • Show what’s pending. React’s useTransition gives you an isPending flag for exactly this. React docs, useTransition
  • Design the drop. Drop indicators, drag handles and keyboard alternatives. Atlassian, Pragmatic drag and drop
  • Respect reduced motion. Tone animations down for people who ask their system for less motion. MDN, prefers-reduced-motion

Queue it, but don’t be optimistic!

It’s a common misconception that a queue makes optimistic updates honest, as in: keep retrying, and the change syncs eventually. But the queue doesn’t sync across devices. However, combining queues and immediate intent is actually even better.

  • Retries stop with the app. On the web, syncing after the page is closed needs the Background Sync API, which Safari and Firefox don’t support. MDN, Background Synchronization API
  • The system decides. iOS only promises not to run your background task too early, not when it will run. Apple, earliestBeginDate
  • On the web, the queue can be evicted. Browsers may delete a site’s stored data when space runs low, and Safari clears sites you haven’t used lately. navigator.storage.persist() asks to keep it. MDN, Storage quotas and eviction criteria
  • Show what’s not synced. Tell people what state their data is in, so switching devices holds no surprises. web.dev, Offline UX design guidelines
  • Make late syncs safe. A change that syncs hours later, or twice, must not apply twice. Stripe, Designing APIs with idempotency

Agree? Spread the word.

Share this page with your team and give it a star on GitHub. Let’s build reliable software people can trust.

Know a good, harmless use case for optimistic updates?Let’s discuss it. I’m curious!

Receiving side

  • Getting fewer likes than peers causes distress, especially in teens who’ve been bullied. Lee et al., 2020
  • Many people care more about who liked their post than how many did. Scissors et al., 2016
  • When a Twitter bug dropped like counts, users assumed their tweets were bad. TechCrunch, 2019

Sending side

  • People see a like as social support, so a lost like is support your friend never got. Wohn et al., 2016
  • A like says as much about the relationship as about the post, so a missing one says something too. Hayes et al., 2016

The text above was extracted automatically from the source page and may miss images, tables or code blocks. The original is authoritative.

Published by Lobsters
This site only summarises and aggregates; copyright stays with the original author. Headlines and summaries follow the source — where they differ, the original wins.
Read the original ↗