Calibre is a modern, statically-typed language built in Rust with a fast interpreter, a growing toolchain, and a pragmatic syntax for systems scripting. It emphasizes clear data modeling, expressive pattern matching, and straightforward FFI via extern with explicit C/Zig types.
- Statically Typed: Type inference and explicit typing for safety and expressiveness.
- Pattern Matching: Powerful
matchfor enums, tuples, and structs. - Enums & Structs: Algebraic data types with tuple and map-like variants.
- Immutability by Default:
letfor immutable,let mutfor mutable variables. - First-Class Functions: Functions as values, with concise syntax.
- FFI:
extern "c"/extern "zig"with@-typed signatures andptr:<T>pointers. - Interpreted Execution: Fast iteration with a bytecode VM.
- Tooling: Tree-sitter grammar, formatter (
fmt) with max-width option, and LSP (in progress).
type Point = struct {
x: int,
y: int,
};
const dot = fn(p: Point) -> int => p.x * p.y;
const classify = fn match &int {
.Ok : value => "ok: " & value,
.Err : msg => "err: " & msg,
};
const main = fn() => {
let p = Point { x: 6, y: 7 };
print(dot(p));
let mut a, mut b = 10, 20;
print(a + b);
};extern "c" const c_strlen = fn(str) -> @usize from "..." as "strlen";
extern "zig" const zig_add = fn(@i32, @i32) -> @i32 from "..." as "zig_add";
const main = fn() => {
print(c_strlen("hello"));
print(zig_add(40, 2));
};-
Clone the repository:
git clone https://github.com/CodersCreative/calibre-lang.git cd calibre-lang/cal -
Run a REPL:
cargo run -p cal
-
Run an example:
cargo run -p cal -- ../examples/examples.cl
-
Format code (optional):
cargo run -p cal-fmt -- --max-width 100 --path ../examples/examples.cl
-
Install cal
cargo install -p cal
-
Install cal-fmt
cargo install -p cal-fmt
- Interpreter backend
- Cranelift backend (
crates/cranelift) - Tree-sitter grammar (https://github.com/CodersCreative/tree-sitter-calibre)
- Formatter ('fmt')
- Language Server Protocol (LSP) (
lsp) - Package manager
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
MIT License. See LICENSE for details.
cal/: Main interpreter frontendfmt/: Formatter implementationcrates/: Core language crates (parser, interpreter, VM, etc.)examples/: Example Calibre programs (including FFI and Zig)lsp/: Language Server Protocol implementation (in progress)