The Cryo programming language.
Cryo is statically typed and compiles to native machine code through LLVM 20. It has generics, algebraic enums, pattern matching, traits, and trait objects, with manual allocation, raw pointers, and no garbage collector underneath them.
The compiler and the standard library are written in Cryo, and one binary builds, tests, and ships your project.
curl -fsSL https://cryolang.org/install.sh | bashInstall guideLanguage referencePlayground
LLVM 20 / Linux, Windows / Apache-2.0
import std::fmt;
type enum Shape {
Circle(f64);
Rectangle(f64, f64);
Point;
}
function describe(s: Shape) -> void {
match (s) {
Shape::Circle(r) => { fmt::printf("Circle r=%f\n", r); }
Shape::Rectangle(w, h) => { fmt::printf("Rect %f x %f\n", w, h); }
Shape::Point => { fmt::printf("A point\n"); }
}
}import a::b;
import a::b::{ X, Y };
import a::b as c;
import a::b::*;Brings a module, or selected items from it, into scope. One path per declaration: use the brace form for several items, as to alias, and * for everything public (prefer the brace form; wildcards invite name collisions).
type struct Name { ... }
type enum Name { ... }
type trait Name { ... }
type union Name { ... }Begins a type declaration; the keyword that follows says which kind. On its own, type Name = Existing; declares an alias.
type enum Name {
Unit,
Payload(T),
Named { x: i32 },
}An algebraic data type. Variants may be bare or carry a tuple or struct payload, and a match on an enum must cover every variant. Name::Variant names a variant; methods are added with implement enum Name { ... }.
type enum ShapeShape::Circle(f64)Shape::Rectangle(f64, f64)Shape::Pointfunction name<T>(param: Type) -> Ret { ... }Declares a function. Parameters are written name: Type and are never inferred; the return type follows -> and defaults to void. Declaration order does not matter: every signature is collected before any body is checked, so functions may call each other freely and recurse.
function describe(s: Shape) -> void(parameter) s: Shapetype enum Shapematch (subject) {
Pattern(x) => { ... }
_ => { ... }
}The primary discriminator: branches on enum variants, integers, ranges, constants, and tuple and destructuring patterns, such as (0, 1..8) or Option::Some((count, _)), and the compiler rejects a match that misses a case. There is no fallthrough. As an expression it evaluates to the chosen arm's value, so every arm must produce the same type.
(parameter) s: ShapeShape::Circle(f64)r: f64pattern => { body }Separates a match arm's pattern from its body. Arms do not fall through.
function printf(fmt: string, args...) -> i32Write a printf-style formatted string to stdout. Returns the number of bytes written, or a negative value on error (libc printf convention). The legacy text path, kept public and supported; for value formatting write an f-string through println (Display-based) below.
r: f64Shape::Rectangle(f64, f64)w: f64h: f64w: f64h: f64Shape::PointToolchain
A project is a directory with a cryoconfig file. Scaffold it, build it, test it, and resolve its git dependencies with the same binary that compiles it. There is no build system to assemble.
- cryo init
- Scaffold a project - cryoconfig plus src/main.cryo.
- cryo build
- Compile the project. Incremental by default.
- cryo run
- Build, then execute the resulting binary.
- cryo test
- Discover and run every ![test] function, fork-per-test.
- cryo check
- Front-end and semantic analysis only; no codegen.
- cryo fetch
- Resolve dependencies and write cryoconfig.lock.
cryo init hellocd hellocryo run Compiling hello v0.1.0 Finished release [optimized] target(s) Running `build/hello`Hello, world!In 1.0.0
- Self-hosted compiler
- Every line of Cryo you compile is compiled by a compiler written in Cryo. A 3-round, 6-stage build asserts the emitted IR is byte-identical between rounds, and it gates every push.
- Monomorphised generics
- Type parameters with where-bounds, specialised per instantiation. Abstractions compile down to the code you would have written by hand.
- Deterministic destruction
- Drop glue is synthesised recursively through struct fields, enum payloads, and container elements. Nothing is deferred to a collector, so release order is the reverse of declaration order, every time.
- Async with no pinning
- An async function compiles to a state machine that is an ordinary value type. Futures are never self-referential, so they move freely and cancellation is just a drop.
- Standard library
- Collections, iterators, JSON, YAML and TOML, filesystem, threads, channels, atomics, TLS, HTTP/1.1 and HTTP/2 clients and servers, and WebSocket - written in the language, shipping with the compiler.
- C FFI
- Declare C functions by hand, or import a whole header under an alias and let the compiler synthesise the bindings. static_assert verifies your layouts against the C ABI.
Standard library
Written in the language and shipped with the compiler. Browse the module reference.
- coreOption, Result, Slice, iterators, traits, memory utilities
- allocBox, Rc, Arc, Arena, Pool, Allocator
- collectionsArray, String, Str, HashMap, BTreeMap, Deque
- ioRead/Write traits, buffered wrappers, stdio
- fmtDisplay, Debug, Formatter, the print family
- encodingJSON, YAML and TOML through one Value model; Base64, hex
- fsPath, PathBuf, File, OpenOptions, directory walking
- netTCP, UDP, TLS, HTTP/1.1, HTTP/2, WebSocket
- syncAtomic<T>, Mutex, ReadWriteLock, ConditionVariable, channels
- threadspawn, JoinHandle, scoped threads, thread-locals
- timeDuration, Instant, SystemTime, sleep
- testThe built-in unit-test framework