Jolt:使用 Chez Scheme 实现的 Clojure 编译器
Jolt: Clojure compiler implemented with Chez Scheme

原始链接: https://jolt-lang.github.io

Jolt 是一个运行在 Scheme(原生支持 Chez,或 JavaScript 环境下的 Gambit)之上,而非 JVM 之上的自托管 Clojure 实现。它提供了一个轻便且功能完备的 Clojure 开发体验,包括惰性序列、转换器(transducers)、持久化数据结构、多重方法(multimethods)和协议(protocols)。 主要特性包括: * **独立二进制文件:** `jolt build` 命令可创建自包含的可执行文件,无需外部运行时或 JVM。 * **Clojure 语义:** 保持了 Clojure 的数值塔、并发原语(futures、agents、`core.async`)以及完整的读取器(reader)。 * **自托管:** 使用 Clojure 编写,编译器能够编译自身。 * **兼容性:** 虽然 Jolt 忠实地实现了 Clojure 语义,但它用基于 Scheme 的替代方案取代了 JVM 特有的功能。值得注意的是,它不支持 Java 互操作和 `BigDecimal`,但提供了用于系统集成的 C FFI。 Jolt 旨在实现高效与便携,使开发者能够使用标准的 Clojure 代码创建轻量级的原生应用程序。它是开源的(采用 Eclipse Public License 1.0 协议),可通过 Homebrew 或 Shell 脚本立即安装。

Hacker News 社区正在讨论由资深开发者 Dmitri Sotnikov(yogthos)创建的“Jolt”。这是一个针对 Chez Scheme 的新型 Clojure 编译器。 Jolt 旨在提供一种快速、独立的 JVM 原生替代方案,使 Clojure 代码在运行性能媲美 JVM 的同时,还能支持原生 FFI 和现有库。由于该项目开发周期仅两个月,引发了广泛争议。一些批评者因其高频率的提交记录以及利用大语言模型(LLM)加速实现,将其贴上“AI 垃圾(AI slop)”或“AI 拼凑(vibe-coded)”的标签。 Sotnikov 为此辩护称,Clojure 社区早已确立了底层的语言设计,这使他能够专注于通过广泛的测试套件和基准测试进行移植与验证。支持者则认为,该项目与典型的低质量 AI 输出不同,作者充分利用了深厚的领域专业知识,并将 AI 作为“具备语法意识的打字员”来加速对明确规范的转换,是一个很好的应用案例。尽管一些用户对其生产环境的就绪程度持谨慎态度,但早期采用者已成功使用 Jolt 构建了小型、独立的本地可执行文件。
相关文章

原文
Jolt — Clojure on Scheme

Jolt is a self-hosted Clojure implementation that runs on Scheme — Chez natively, Gambit for JavaScript. No JVM, no build step — most portable Clojure runs unchanged.

  • The compiler is written in Clojure and compiles itself
  • Persistent data, lazy seqs, transducers, multimethods, protocols — full Clojure semantics
  • Real concurrency: future, agent, pmap, and core.async on OS threads
  • jolt build emits a single standalone binary — no Scheme or JVM needed to run it

The terminal on the right is jolt itself — compiled to JavaScript by the Gambit backend — evaluating live in your browser. It runs a reduced build to keep the download small, so regex is left out here and says so if you reach for it.

jolt via Gambit → JS repl

user=> (->> (range 10) (filter even?) (map #(* % %)) (reduce +))

120

Why Jolt?

Self-Hosted Compiler

Reads Clojure, analyzes it to a host-neutral IR, emits Scheme, and runs it — on Chez natively, or on Gambit compiled to JavaScript. The compiler is written in Clojure and compiles itself.

Standalone Binaries

jolt build ahead-of-time compiles a project — runtime, standard library, app, and its deps — into a single self-contained executable. No Chez, no JVM, no source needed to run it.

Real Concurrency

future/promise/agent/pmap run on OS threads over a shared heap, matching JVM semantics. core.async provides channels and go blocks.

Full Numeric Tower

Exact integers and bignums, exact ratios ((/ 1 2)1/2), and flonum doubles. = is category-aware; == is value-equality.

Persistent Data

Immutable vectors (32-way tries), cons lists, and HAMT maps/sets with Clojure value semantics. Transients are real mutable scratch collections.

Clojure-Compatible

Lazy/infinite seqs, transducers, destructuring, multimethods, protocols/records, metadata, namespaces, runtime eval, and the full reader.

Quick Start

Install the self-contained jolt binary — it bundles the runtime, compiler, and standard library, so there's nothing else to install.


brew install jolt-lang/jolt/jolt


curl -sL https://raw.githubusercontent.com/jolt-lang/jolt/main/install | bash

jolt -e '(+ 1 2)'        

Or run from a clone (needs Chez Scheme) — no build step, the bootstrap seed is checked in:

git clone --recurse-submodules https://github.com/jolt-lang/jolt.git
cd jolt
bin/jolt -e '(+ 1 2)'        

Usage

Evaluate an expression

$ bin/jolt -e '(->> (range 10) (filter even?) (map (fn [x] (* x x))) (reduce +))'

$ bin/jolt -e '(/ 1 2)'

Run a project

bin/jolt run -m myapp.core   
bin/jolt -M:test [args]      
bin/jolt path                

Compile a standalone binary

bin/jolt build -m myapp.core -o myapp   
./myapp arg1 arg2                        

nREPL

bin/jolt --nrepl-server      

Develop against a live process: see REPL-Driven Development.

Read the documentation for installation, writing libraries, and host interop.

Differences from Clojure

Jolt targets Clojure semantics but runs on Scheme, not the JVM. Most portable Clojure runs unchanged — persistent collections, the numeric tower, lazy seqs, transducers, multimethods, protocols/records, atoms, future/agent/pmap, core.async, runtime eval, and the full reader all behave as on the JVM. The genuine divergences:

AspectDifference
Java interopNo JVM, so no general Java interop, reflection, or gen-class/proxy — a shimmed subset of java.* is available, plus a C FFI
BigDecimalNot available (decimal? is always false); the rest of the numeric tower matches
RegexCompiled by irregex, not java.util.regex — common patterns work, some Java-specific features differ
联系我们 contact @ memedata.com