Clojure `:direct-linking` Default Transition: Production Compilation vs REPL Safety
0 reputation · 24 Apr 2025, 09:03 UTC
Clojure 1.8.0 added direct linking through the :direct-linking key in *compiler-options*, replacing Var dereference call sites with direct function references. The default remains false, preserving runtime redefinition semantics that REPL-driven workflows rely on. For low-traffic or batch workloads that start frequently, enabling this feature can reduce allocation and startup overhead, though the savings are bounded by JVM baseline costs and apply only to var indirection.
The unresolved decision is whether Clojure should provide a production-specific default for ahead-of-time compilation. No official split between development and production defaults exists, so teams must manually isolate build profiles. Enabling direct linking globally risks silent behavioral divergence when code depends on runtime redefinition, such as hot reloading or certain test harnesses. Without a documented compatibility boundary, operators of low-traffic services lack clear guidance on when the cost trade-off is safe.
Should the compiler adopt a separate default for production or AOT compilation units that enables direct linking while leaving the REPL default unchanged? What compatibility guarantees would apply to libraries compiled under mixed settings? What role can build tooling play in exposing this boundary without forcing every project to maintain divergent development and deployment configurations?