Continuations essay: add argument that they're easier to reason about than workarounds

Without call/cc you get callback pyramids, state machines, command
pattern undo stacks, Promise chains, and framework-specific hooks —
each a partial ad-hoc reinvention of continuations with its own edge
cases. The complexity doesn't disappear; it moves into user code.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-04 10:42:08 +00:00
parent fd67f202c2
commit da8d2e342f

View File

@@ -2927,7 +2927,23 @@ def _essay_continuations() -> str:
f' {p}'
' "The key insight: having the primitive available doesn\'t make the evaluator '
'harder to reason about. Only code that calls call/cc pays the complexity cost. '
'Components that don\'t use continuations behave exactly as they do today."))'
'Components that don\'t use continuations behave exactly as they do today.")'
f' {p}'
' "In fact, continuations can be easier to reason about than the hacks '
'people build to avoid them. Without call/cc, you get callback pyramids, '
'state machines with explicit transition tables, command pattern undo stacks, '
'Promise chains, manual CPS transforms, and framework-specific hooks '
'like React\'s useEffect/useSuspense/useTransition. Each is a partial, '
'ad-hoc reinvention of continuations — with its own rules, edge cases, and leaky abstractions.")'
f' {p}'
' "A wizard form built with continuations is a straight-line let* binding. '
'The same wizard built without them is a state machine with a current-step variable, '
'a data accumulator, forward/backward transition logic, and a render function '
'that switches on step number. The continuation version has fewer moving parts. '
'It is more declarative. It is easier to read.")'
f' {p}'
' "The complexity doesn\'t disappear when you remove continuations from a language. '
'It moves into user code, where it\'s harder to get right and harder to compose."))'
# --- What this means for SX ---
@@ -2942,11 +2958,9 @@ def _essay_continuations() -> str:
'and elegant undo. These aren\'t theoretical — they\'re patterns that '
'React, Clojure, and Scheme have proven work.")'
f' {p}'
' "The question isn\'t whether continuations are useful. '
'It\'s whether SX needs them now or whether async/await and HTMX cover enough. '
'The answer, for now, is that they\'re worth building — '
'because the evaluator is already 90%% of the way there, '
'and the remaining 10%% unlocks an entirely new class of UI patterns."))'
' "The evaluator is already 90%% of the way there. '
'The remaining 10%% unlocks an entirely new class of UI patterns — '
'and eliminates an entire class of workarounds."))'
')'
)