A Twitter spat between Lisp advocate @Ngnghm and Koru language promoter @korulang boiled down to one question: can Common Lisp match C’s speed with truly idiomatic code? They settled on the nbody benchmark from the Computer Language Benchmarks Game, a simulation of 5,000 celestial bodies under gravity using O(n²) pairwise forces. Koru claims its straightforward kernel beats idiomatic C by 14% and Lisp by over 100% on unspecified hardware.
This matters because nbody stresses floating-point arithmetic, cache locality, and loop fusion—real-world concerns in simulations for physics, finance modeling, or crypto price forecasting. If a new language like Koru (a low-level systems tongue akin to Zig or Rust) outpaces Lisp and C without tricks, it challenges Lisp’s “adapt the language” philosophy. Lisp fans argue you extend the language with macros for optimal expression; critics say that yields bloated, non-idiomatic messes.
Benchmark Breakdown
Koru’s blog post shows times for n-body with 5k bodies over 0.1s steps, repeated for measurement. Their “naive” Koru code: fused loops computing accelerations inline, no separate position/velocity updates. Results (likely on x86-64, Linux, recent GCC/Clang):
- Koru: baseline (say, 1.00x)
- C (gcc -O3): 1.14x slower
- SBCL Lisp: 2.06x slower
They later tweak C with loop fusion and SIMD intrinsics to tie Koru, calling it “unidiomatic.” Fair point—stock C from Benchmarks Game uses separate passes, hurting cache. But Lisp’s entry? SBCL’s default nbody clocks around 1.5-2x C on AMD/Intel setups, per public runs on benchmarksgame-team.pages.debian.net. On a Ryzen 9 7950X, top C (gcc) hits ~0.25s for full run; SBCL ~0.45s. Koru’s edge holds if their kernel fuses better, but they omit CPU model, libc version, and compiler flags beyond -O3/no -ffast-math.
Skepticism warranted: Koru code looks LLM-polished (they admit it), and nbody favors languages with easy aliasing control. Lisp’s GC pauses? Negligible here—SBCL allocates little. Real gap: Lisp loops less aggressive on inlining/autovectorization versus C’s explicit control.
Defining ‘Idiomatic’ Code
Idiomatic means fluent, leveraging language strengths without fighting idioms. C: terse structs, pointer arithmetic, plain for-loops. Lisp: s-expressions, higher-order functions, macros for DSLs. Koru’s “straightforward” fuses loops idiomatically because its syntax encourages kernel-style blocks—explicit parallelism hints maybe.
Lisp adapts via macros. Example: define a defkernel macro wrapping loops in fused form, declaring types for SBCL optimization. Result? Code reads like math: (defkernel nbody-step (bodies dt) ...). Compiles to machine code rivaling C. Benchmarks Game’s Lisp isn’t maximally idiomatic—lacks such extensions. With them, SBCL hits C parity in nbody, per @Ngnghm’s repos.
Why care? Performance != productivity forever. In finance/crypto sims, 2x slowdown cascades: backtests take hours not minutes. But Lisp’s macro power lets you invent SIMD loops or GPU offload DSLs. Koru forces low-level tweaks; Lisp raises them to language level.
Implications and Reality Check
Lisp wins on expressiveness for adaptive domains—AI, config-heavy finance tools—where C/Koru drown in boilerplate. Raw speed? Competitive post-tuning. Public Benchmarks Game (2023 data): SBCL #3 overall, behind only optimized C/Rust, beating Go/Java by 10-50x in some.
Koru’s win is real but narrow—fused nbody favors its design. Run it yourself: clone Koru repo, build with their LLVM backend, compare on your iron. Lisp scales via extensions; don’t shoehorn problems. For security/crypto code (e.g., elliptic curves), Lisp’s provable macros beat C’s footguns.
Bottom line: Lisp isn’t “slow.” It demands adaptation, yielding code as fast as C when you invest. Koru proves low-level pays, but Lisp’s meta-programming endures for complex systems. Pick by problem: sims? Fuse loops. Evolving algos? Lisp.