Scripts2026年7月17日·1 分钟阅读

Babashka — Fast Native Clojure Scripting for the Command Line

A native, fast-starting Clojure interpreter for scripting, built with GraalVM native-image, that starts in milliseconds and provides a rich set of built-in libraries.

Agent 就绪

先审查再安装

这个资产需要先审查。复制的指令会要求 Agent dry-run、列出写入项,确认后再继续。

Needs Confirmation · 64/100策略:需确认
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
Babashka Overview
先审查命令
npx -y tokrepo@latest install 88a1c2a2-81dd-11f1-9bc6-00163e2b0d79 --target codex

先 dry-run,确认写入项后再运行此命令。

Introduction

Babashka is a native Clojure interpreter designed for scripting. Unlike standard Clojure which requires JVM startup time, Babashka starts in under 10 milliseconds thanks to GraalVM native compilation. It brings the expressiveness of Clojure to shell scripting, data processing, and automation tasks where JVM startup overhead would be prohibitive.

What Babashka Does

  • Runs Clojure scripts with near-instant startup (under 10ms)
  • Includes a rich standard library with built-in support for JSON, YAML, CSV, HTTP, and SQL
  • Provides a babashka.process namespace for shell command execution
  • Supports running tasks defined in a bb.edn project file (like a Clojure Makefile)
  • Executes multi-file projects with namespace resolution and dependency management

Architecture Overview

Babashka is built on the Small Clojure Interpreter (SCI), which interprets Clojure code without JVM compilation. SCI is compiled to a native binary using GraalVM native-image, bundling the interpreter and all included libraries into a single executable. The result is a self-contained binary that provides most of Clojure's functionality with startup times comparable to Bash or Python.

Self-Hosting & Configuration

  • Install via Homebrew, the official bash installer, or download prebuilt binaries from GitHub releases
  • Available for Linux (x86_64, aarch64), macOS (x86_64, aarch64), and Windows
  • Configure project-level tasks and dependencies in a bb.edn file at the project root
  • Dependencies from Clojars and Maven can be loaded at runtime via the :deps key in bb.edn
  • Use bb.edn tasks as a cross-platform alternative to Makefiles or npm scripts

Key Features

  • Near-instant startup makes it practical for CLI tools and git hooks
  • Built-in libraries for HTTP clients, JSON/YAML/CSV parsing, and SQLite access
  • Compatible with a large subset of Clojure, including most of clojure.core
  • Task runner (bb tasks) for defining project automation in Clojure
  • Extensible via pods — external processes that communicate via bencode over stdin/stdout

Comparison with Similar Tools

  • Clojure (JVM) — full language with long startup; Babashka trades some features for instant start
  • Bash — ubiquitous but limited data structures; Babashka offers Clojure's rich collections
  • Python — similar scripting use case; Babashka starts faster and has immutable-first data
  • Deno — fast TypeScript scripting runtime; Babashka serves the Clojure ecosystem
  • Nushell — structured data shell; Babashka provides a full programming language

FAQ

Q: Is Babashka a full Clojure implementation? A: It supports most of Clojure's standard library but not all. Features requiring JVM interop (like Java class loading) are not available.

Q: Can I use Clojure libraries from Clojars? A: Yes, as long as they don't require JVM-specific features. Many popular libraries work out of the box.

Q: How does it compare to Planck or Joker? A: Planck uses ClojureScript on JavaScriptCore; Joker is a Go-based interpreter. Babashka offers the broadest library support and most active development.

Q: Can I build standalone CLI tools with Babashka? A: Yes. You can distribute scripts as single files or use bb.edn projects with dependencies bundled.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产