Calcit Scripting Language
Semantically a dialect of ClojureScript. Built with Rust. Compiles to JavaScript ES Modules.
- Home https://calcit-lang.org/
- API Doc https://apis.calcit-lang.org/
- Guidebook https://guide.calcit-lang.org/
Browse examples or also try WASM version online.
Core design:
- Interpreter runs on Rust, extensible with Rust FFI
- Persistent Data Structure
- Indentation-based Cirru syntax, friendly to plain text editing
- Lisp macros, functional style
- Compiles to JavaScript in ES Modules, JavaScript Interop
- Hot code swapping friendly
Current direction:
calcit.cirruis the primary source snapshot; legacycompact.cirruis still compatible- CLI-first development with
crandcaps, designed to work well with AI agents in terminal workflows - Better CLI editing and validation for CI, docs lookup, module management, and incremental updates
Install 
Build and install with Rust:
# get Rust
|
# get Calcit user-facing tools
Installed binaries:
cr, the runtime and JS compilercaps, for downloading dependencies declared indeps.cirru
When installing from source, install the same public tools:
To use Calcit in GitHub Actions, try setup-cr.
Quick Start
Evaluate snippets:
Run with a runtime snapshot such as calcit.cirru (legacy filename: compact.cirru):
By default Calcit reads :init-fn and :reload-fn from calcit.cirru configs (falling back to compact.cirru). You may also specify functions:
You may also configure :entries in calcit.cirru:
JavaScript codegen
Calcit compiles to JavaScript with consistent semantics. In browser or Node projects, JavaScript interop is still expected.
By default, js code is generated to js-out/. You will need Vite or Node to run it, from an entry file:
import from "./js-out/app.main.mjs";
; // which corresponds to `main!` function in calcit
CLI and Agent Workflow
The recommended workflow is plain text editing plus CLI validation, often driven by an AI agent in terminal.
Common commands:
Calcit Editor is no longer the recommended path for everyday development. If you still need the older editor workflow, see Calcit Editor.
Related examples and workflows:
- Minimal Calcit
- Respo Calcit Workflow
- setup-cr for GitHub Actions
Modules
deps.cirru declares dependencies that need to download, which correspond to repositories on GitHub. Specify a branch or a tag:
{}
:calcit-version |0.9.11
:dependencies $ {}
|calcit-lang/memof |0.0.11
|calcit-lang/lilac |main
:dev-dependencies $ {}
|calcit-lang/calcit-test |0.1.0
Run caps to resolve the recursive dependency graph and install it. Immutable revisions are stored under
~/.config/calcit/modules/.store/, while the current project receives links under .calcit/modules/.
Different projects can therefore use different revisions without switching a shared checkout. Existing
~/.config/calcit/modules/<repo>/ checkouts remain a runtime fallback during migration.
Published SemVer tags are preferred. Branch refs remain supported for development, but caps warns with
the resolved commit. When a graph requests several SemVer tags for one repository, the highest requested
version is selected and reported.
Root projects install both :dependencies and :dev-dependencies. Recursive resolution only follows
:dependencies, so test and maintenance modules declared by a dependency do not leak into consumers.
Use caps add --dev <org/repo>@<ref> and caps remove --dev <org/repo> to manage the development group.
:calcit-version helps with version checks and provides hints in CI.
To load modules, use :modules configuration and the runtime snapshot file calcit.cirru (legacy: compact.cirru):
:entries $ {}
:default $ {}
:modules $ [] |memof/calcit.cirru |lilac/
Paths defined in :modules first load from the snapshot directory's .calcit/modules/, then fall back to
~/.config/calcit/modules/, i.e. .calcit/modules/memof/calcit.cirru or the legacy global path.
Modules ending with / are automatically suffixed with calcit.cirru, and still fall back to compact.cirru for compatibility.
Inspect and verify the resolved graph with:
Development
Local validation commands:
# run tests in Rust
# run tests in Node.js
&&
# run snippet
# internal compiler/WASM validation when working on this repository
For repository development, the usual validation flow is:
- Cirru Parser for indentation-based syntax parsing.
- Cirru EDN for runtime snapshot file parsing (
calcit.cirru/ legacycompact.cirru). - Ternary Tree for immutable list data structure.
Other tools:
- Error Viewer for displaying
.calcit/error.cirru - IR Viewer for rendering
program-ir.cirru
Some resources:
- Dev Logs https://github.com/calcit-lang/calcit/discussions
- 视频记录 https://space.bilibili.com/14227306/channel/seriesdetail?sid=281171
License
MIT