Features
Calcit's language features form one coherent model around immutable data, nominal domain types, capability-oriented methods, explicit effects, and cross-backend execution.
Core Features
- Immutable persistent data structures - All data is immutable by default using ternary tree implementations
- Functional programming - First-class functions, higher-order functions, closures
- Code as data - Cirru syntax trees and macros provide language-level abstraction without adding parser syntax for every feature
- Hot code swapping - Live code updates during development without state loss
- JavaScript interop - Seamless integration with JS ecosystem via ES Modules
- Static type analysis - Compile-time type checking and error detection
Calcit-specific design
- Indentation-based syntax - Cirru indentation,
$, and local parentheses describe Calcit syntax trees directly - Structural source operations - CLI queries and edits operate on canonical
calcit.cirrusyntax trees - ES Modules output - Modern JavaScript module format, tree-shakeable
- MCP integration - Model Context Protocol server for AI assistant tool integration
- Ternary tree collections - Custom persistent data structures optimized for Rust
- State-preserving reload - Watch mode recompiles and invokes explicit reload functions
- Pattern matching - Tagged unions with compile-time validation
- Struct types - Fixed-field values with required field access validation
- Traits & method dispatch - Attach capability-based methods to values, with explicit disambiguation when needed
- Typed FFI capabilities - Native and JavaScript host APIs retain explicit typed boundaries
- Revisioned application protocols - Nominal message envelopes support deterministic incremental synchronization
Language Features
For detailed information about specific features:
- List - Persistent vectors and list operations
- HashMap - Key-value data structures and operations
- Macros - Code generation and syntax extension
- JavaScript Interop - Calling JS from Calcit and vice versa
- Imports - Module system and dependency management
- Polymorphism - Object-oriented programming patterns
- Traits - Capability-based method dispatch and explicit trait calls
- Static Analysis - Type checking and compile-time validation
Compilation Targets
- JavaScript Codegen - Generate ES Modules from Calcit
Quick Find by Task
Use this section as a keyword index for calcit docs read:
- Collections: list, map, set, struct, enum
- Pattern Matching: enum, match, anonymous enum, result, exhaustiveness
- Types: static-analysis, assert-type, optional, variadic
- Methods: trait, impl-traits, method dispatch, trait-call
- Interop: js interop, async, promise, js-await
- Architecture: imports, namespace, module, dependency
Task-oriented jump map:
- Data transforms → List, HashMap, Sets
- Domain modeling → Records, Enums, Tuples
- Type safety → Static Analysis, Error Handling
- Extensibility → Macros, Traits, Polymorphism
- Runtime integration → JavaScript Interop, Imports
- Real-time architecture → Real-time Application Model
Development Features
- Type inference - Automatic type inference from literals and expressions
- Compile-time checks - Arity checking, field validation, bounds checking
- Error handling - Rich stack traces and error messages with source locations
- Package management - Git-based dependency system with
capsCLI tool - Hot module replacement - Fast iteration with live code updates
- REPL integration - Interactive development with
calcit evalmode - Bundle mode - Single-file deployment with
calcit bundle
Type System
Calcit's static analysis provides:
- Function arity checking - Validates argument counts at compile time
- Struct field validation - Checks that required fields exist in struct definitions
- Enum bounds checking - Validates positional enum payload access
- Enum variant validation - Ensures correct enum construction
- Method existence checking - Verifies methods exist for types
- Recur arity validation - Checks recursive calls have correct arguments
- Return type validation - Matches function return types with declarations
Performance
- Native execution - Rust interpreter for fast CLI tools and scripting
- Zero-cost abstractions - Persistent data structures with minimal overhead
- Lazy sequences - Efficient processing of large datasets
- Optimized compilation - JavaScript output with tree-shaking support
- Type-directed optimizations - Compile-time rewrites for struct field access/update when types are known (e.g.,
&struct:assoc→&struct:assoc-at)
Calcit is designed as its own language: historical influences remain useful context, but current APIs and documentation follow Calcit's nominal types, traits, method-oriented capabilities, typed effects, and real-time application model.