A modern, statically typed, compiled programming language. It was created to evolve with my learning about Rust. So, test it just for fun. "Code that reads like thought, runs like metal."
# Install (from source)
git clone https://github.com/crialang/cria
cd cria
cargo build --release
# Create a project
cria init hello
cd hello
cria runfn main() {
println!("Hello, World!")
}
use std.http.{Server, Request, Response}
use std.collections.Map
// Structs with derived traits
@derive(Debug, Clone)
struct User {
id: Int
name: String
email: String
}
// Algebraic data types
enum AuthResult {
Success(User)
InvalidCredentials
AccountLocked { until: DateTime }
}
// Async/await + error handling
async fn authenticate(email: String, password: String) -> Result[AuthResult, DbError] {
let user = await db.find_by_email(email)?.ok_or(AuthResult.InvalidCredentials)?
if user.is_locked() {
return Ok(AuthResult.AccountLocked { until: user.locked_until })
}
if await password.verify(user.password_hash)? {
Ok(AuthResult.Success(user))
} else {
Ok(AuthResult.InvalidCredentials)
}
}
// Pattern matching
fn handle_auth(result: AuthResult) -> Response {
match result {
AuthResult.Success(user) => {
let token = jwt.sign(user.id)
Response.ok({"token": token})
}
AuthResult.InvalidCredentials =>
Response.unauthorized("invalid credentials")
AuthResult.AccountLocked { until } =>
Response.forbidden("account locked until $until")
}
}
// Generics + traits
trait Repository[T] {
async fn find(self, id: Int) -> Result[Option[T], DbError]
async fn save(self, item: T) -> Result[T, DbError]
async fn delete(self, id: Int) -> Result[Bool, DbError]
}
// List comprehensions
fn active_users(users: List[User]) -> List[String] {
[u.name for u in users if u.is_active()]
}
// Main entry point
async fn main() -> Result[(), Error] {
let server = Server.new("0.0.0.0:8080")
println!("Listening on :8080")
await server.serve(handle_auth)?
Ok(())
}
| Feature | Status |
|---|---|
| Static typing + inference | ✅ |
| Generics + traits | ✅ |
| Pattern matching | ✅ |
| Async/await | ✅ |
| No null (Option[T]) | ✅ |
| Result[T,E] error handling | ✅ |
| Native binary output | 🔄 WIP |
| WebAssembly target | 📋 Planned |
| Package manager | 📋 Planned |
| LSP / VS Code extension | 📋 Planned |
compiler/ criac — lexer, parser, type checker, codegen
runtime/ VM, GC, async scheduler
cli/ cria — the user CLI tool
package-manager dependency resolution & registry
lsp/ Language Server Protocol server
std/ Standard library (written in Cria)
vscode-extension VS Code integration
docs/ Language spec & book
The Cria toolchain is implemented in Rust for:
- Memory safety in the compiler itself
- Excellent LLVM bindings (
inkwell) - Strong ecosystem (cargo, rayon, crossbeam)
- Cross-platform compilation
The workspace compiles with zero errors. The core pipeline skeleton is in place:
| Component | File(s) | Status |
|---|---|---|
| Lexer | compiler/src/lexer/ |
✅ Complete — all tokens, interpolated strings, Unicode, hex/bin/oct literals |
| AST | compiler/src/ast/mod.rs |
✅ Complete — all node types (expr, stmt, pattern, type, items) |
| Parser | compiler/src/parser/mod.rs |
✅ Complete — recursive descent + Pratt for expressions |
| Type checker | compiler/src/typechecker/mod.rs |
🔄 Skeleton — HM unification, collect/check passes |
| HIR | compiler/src/ir/mod.rs |
🔄 Skeleton — three-address code definition |
| Codegen | compiler/src/codegen/mod.rs |
🔄 Stubs — LLVM native, WASM, bytecode VM defined |
| Runtime VM | runtime/src/vm.rs |
🔄 Skeleton — opcode set defined, execution loop pending |
| GC | runtime/src/gc.rs |
🔄 Skeleton — tri-color mark-and-sweep structure ready |
| Async scheduler | runtime/src/scheduler.rs |
🔄 Skeleton — M:N work-stealing structure defined |
| CLI | cli/src/main.rs |
✅ Complete — all commands wired (build/run stubs through compiler) |
| LSP server | lsp/src/main.rs |
🔄 Skeleton — tower-lsp wired, diagnostics working |
| Package manager | package-manager/src/main.rs |
🔄 Skeleton — manifest/lockfile types, resolver stub |
| Stdlib | std/ |
🔄 Partial — Option, Result, List defined in Cria |
| VS Code extension | vscode-extension/ |
🔄 Skeleton — LSP client + commands |
Goal: Every valid Cria program type-checks correctly; clear errors for invalid ones.
- Name resolution pass (symbol table, scope tree, forward references)
- Complete HM inference: let-polymorphism, generics monomorphization
- Trait constraint solving
- Borrow checker (simplified regions — not full Rust lifetimes)
- Effect system (experimental, behind a flag)
Files to work on: compiler/src/typechecker/mod.rs, add compiler/src/resolver/mod.rs
Goal: cria run hello.cria executes a real program end-to-end.
- HIR lowering: typed AST → three-address HIR (
compiler/src/ir/lowering.rs) - HIR → bytecode compiler (
compiler/src/codegen/mod.rsBytecodeBackend) - VM execution loop (
runtime/src/vm.rs) - GC integration (
runtime/src/gc.rs) - Async scheduler execution (
runtime/src/scheduler.rs) - Basic stdlib builtins backed by Rust:
println!,List,Map,String
Goal: cria build --release produces a fast native binary.
- Add
inkwelldependency to compiler - HIR → LLVM IR emission (
compiler/src/codegen/mod.rsNativeBackend) - Link with
cria-runtime(for GC, scheduler, stdlib) - Basic optimizations: inlining, DCE, constant folding
- Target: Linux x86-64 first, then macOS arm64, Windows x64
Goal: Enough stdlib to write real programs.
-
std.core— Iterator trait + adaptors -
std.io—print,read_line,File,stdin/stdout -
std.collections—Map,Set,Queue(backed by RustHashMapetc.) -
std.string—split,trim,contains,replace,format -
std.async—Future,Channel,spawn,sleep -
std.process—args,env,exit -
std.fs—read_to_string,write,read_dir
Goal: cria build --target wasm32 produces a .wasm file runnable in browsers/WASI.
- Add
wasm-encoderdependency - HIR → WASM emission (
compiler/src/codegen/mod.rsWasmBackend) - WASI imports for filesystem/network
- Optimize for size (
--target wasm32 --optimize size)
Goal: cria pkg add http installs and links a real package.
- Package registry server (separate repo)
- HTTP download + SHA-256 checksum verification
- PubGrub version resolver (
package-manager/src/main.rs) - Lockfile write/read + reproducible builds
-
cria pkg publishto registry
Goal: Developer experience on par with Go/Rust.
-
cria fmt— canonical formatter (parse → pretty-print) -
cria lint— linting passes on typed AST - LSP: hover types, go-to-definition, completions, rename
- VS Code extension: syntax highlighting grammar (
.tmLanguage.json) -
cria doc— extract doc comments, generate HTML - REPL: incremental compilation, history
Goal: Rewrite the compiler in Cria itself.
- Compiler is self-hosting:
criaccompiled bycriac - Standard library fully written in Cria (no Rust shims)
- Run
cargo check --workspace— should be clean - Read
docs/book/architecture.mdfor the full pipeline diagram - Read
SPEC.mdfor the language reference - The best next task is Phase 1 — Name Resolver:
- Create
compiler/src/resolver/mod.rs - Walk the
ModuleAST, build aSymbolTable - Replace
Identnodes with resolvedSymbolreferences - Wire it between parser and type checker in
session.rs
- Create
MIT OR Apache-2.0