February 6, 2026
Pause, play, panic
Delimited Continuations vs. Lwt for Threads
Code “sleep” sparks wake‑up brawl: Lwt loyalists vs. pause‑and‑play fans
TLDR: MirageOS’s async world pits Lwt’s chain-everything style against fibers that pause and resume code, with new OCaml 5 effects looming as the next big switch. The crowd is split: some want familiar Lwt with sugar, others bet effects will finally make async code readable—and the memes are savage.
MirageOS lives on events—no old‑school “real” threads here—so developers juggle callbacks, or they reach for helpers like Lwt (a library that chains async tasks) to keep brains from melting. The post rekindled a long‑running feud: monadic Lwt versus “fibers” built with wild “pause and resume” tricks using delimited continuations. Translation: one camp likes clean pipelines; the other wants code that pauses like Netflix and resumes right where it left off. Micro‑benchmarks made a cameo, and everyone grabbed popcorn.
The comments turned it into a time‑travel drama. One user dropped just “2011” like a mic, suggesting we’ve been arguing about this since flip phones. Another swooped in with the 2026 energy: OCaml 5’s “effect handlers” (new language features that make pausing/resuming code a first‑class thing) will make everything more readable than Lwt. Lwt defenders countered that the library has syntax sugar—think the lwt keyword—that already makes async code look normal. Meanwhile, fiber fans kept chanting “no more callback spaghetti,” while Lwt folks warned that fancy continuations can be powerful but spooky. The memes wrote themselves: “monad monks” vs “resume wizards,” “callback lasagna,” and “wake me when the sleep finishes.” It’s less about speed and more about developer sanity—and no one is sleeping on that.
Key Points
- •MirageOS uses an event-driven model without preemptive threads, waking programs on events and running callbacks until block or completion.
- •Lwt provides a monadic interface in OCaml for asynchronous threads with return, bind, and run, and offers syntax extensions like lwt to improve ergonomics.
- •Concerns with Lwt include required code adaptation for blocking operations and performance costs from closure allocation at blocking points.
- •Delimited continuations via the delimcc library enable fibers with restartable exceptions, allowing stack capture and resumption.
- •Lwt_fiber (by Jake Donham) integrates delimcc with Lwt, offering a fiber interface (start, await), and the author prepared microbenchmarks to compare Lwt and fibers.