From da8d2e342f1c45d7f92fcb9ed6423dc871553222 Mon Sep 17 00:00:00 2001 From: giles Date: Wed, 4 Mar 2026 10:42:08 +0000 Subject: [PATCH] Continuations essay: add argument that they're easier to reason about than workarounds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- sx/sxc/sx_components.py | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/sx/sxc/sx_components.py b/sx/sxc/sx_components.py index e54fbb3..b8d6df2 100644 --- a/sx/sxc/sx_components.py +++ b/sx/sxc/sx_components.py @@ -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."))' ')' )