git » homepage.git » commit 2c2b912

Note platform tradeoffs in destination-driven compilation

author Alan Dipert
2026-01-03 18:18:42 UTC
committer Alan Dipert
2026-01-03 18:18:42 UTC
parent 3fa736cf12cfceb6ecba7deb56fae1a4e90669f1

Note platform tradeoffs in destination-driven compilation

md/Lisp/DestinationDrivenCompilation.md +3 -0

diff --git a/md/Lisp/DestinationDrivenCompilation.md b/md/Lisp/DestinationDrivenCompilation.md
index 03d7d5b..ebb5da0 100644
--- a/md/Lisp/DestinationDrivenCompilation.md
+++ b/md/Lisp/DestinationDrivenCompilation.md
@@ -1,6 +1,7 @@
 # DestinationDrivenCompilation
 - Created Thursday 1 January 2026
 - Updated Friday 2 January 2026 (added IR examples)
+- Updated Saturday 3 January 2026 (noted platform tradeoffs and runtime baggage)
 
 Compilers that target hosts with a hard statement/expression split (JavaScript, C, and similar "bracket" languages) have to respect where values are allowed and where only effects make sense. ClojureScript's emitter handled this with context-sensitive emission: every node got an expression-or-statement flag and picked a matching output form. I patterned [JACL](https://tailrecursion.com/git-arr/r/jacl.git/) after that mode because it kept the emitter easy to read while the backend was taking shape. (See the [ClojureScript emitter](https://github.com/clojure/clojurescript/blob/515900f9762102987bda7d53b919dafc0b6c0580/src/clj/clojure/cljs.clj) `:context` handling.)
 
@@ -63,6 +64,8 @@ h(x);
 
 Destination-driven output already looks like the optimized version. If I rewrote JACL to target destinations instead of expression-versus-statement mode, I expect fewer IIFEs, fewer temps, and fewer cleanup passes to bridge the abstraction mismatch with bracketed hosts.
 
+Context-sensitive emission is also the easier compiler to write: it mirrors the host surface syntax and is a more intuitive first refactor when you just need the emitter to land. The tradeoff is runtime baggage from scaffolding and wrappers. On a JIT'd platform (JVM, JavaScript) the baggage tends to get compiled away, so the simpler emitter can be a deliberate choice rather than a naive one. If you're targeting C or another ahead-of-time host, the overhead sticks around and the destination-driven style starts to pay for itself.
+
 Background reading
 - Destination-driven code generation was popularized by Kent Dybvig (see "[Destination-Driven Code Generation](https://scholarworks.iu.edu/dspace/items/d1d06d85-0944-42f7-a783-7d68a2f5f55d/full)").
 - Context-sensitive emission in ClojureScript is visible in its compiler emitter path that threads a `:context` flag per node.