Kraken is an open-source, general-purpose programming language designed for performance, safety, and expressiveness.
Current version: v0.9.3
CI status: build + test + clippy green on Windows, Linux, macOS — see .github/workflows/ci.yml.
- Tuples:
(int, string, bool)with destructuring and pattern matching - Enums: Variant types with payloads (
Option<T>,Result<T, E>) - Pattern Matching: Match expressions with literal, tuple, and enum patterns
- Generics: Generic functions and types with monomorphization
- Range Types:
0..10(exclusive),0..=10(inclusive) - For-In Loops:
for (x in 0..10) { ... } - Range Patterns: Match expressions with range patterns
- Or Patterns:
1 | 2 | 3 -> { ... } - Guard Clauses:
pattern if condition -> { ... } - Exhaustiveness Checking: Compile-time validation of match coverage
- Struct Patterns:
Point { x, y } -> { ... }in match expressions - Partial Patterns:
Point { x, .. }to ignore remaining fields - Let Destructuring:
let Point { x, y } = point; - Function Parameter Destructuring:
fn foo((x, y): (int, int))andfn bar(Point { x, y }: Point) - Enum Struct Payloads:
enum Shape { Circle(int), Point { x: int, y: int } }
?Operator Infrastructure: Full compiler support for try operator syntax- Error Propagation Patterns: Result and Option enum-based error handling
- AST Desugaring Framework: Infrastructure for operator transformations
- Closure Syntax:
|x, y| x + yand|x| { ... }with full type inference - Function Types:
fn(int, int) -> intfor function pointers - Capture Analysis: Automatic detection of captured variables
- Move Closures:
move |x| ...for capture by value - Higher-Order Functions: Functions accepting and returning closures
- Tests: 1,027 lines of tests covering all scenarios
- Type Aliases:
type MyInt = int;with generic support - Impl Blocks:
impl TypeName { ... }for associated functions - Generic Impl Blocks:
impl<T> Vec<T> { ... }syntax support - Visibility Control: Public and private type aliases and methods
- Infrastructure Complete: Full parsing and compiler pass support
- Turbofish Syntax:
::<T>for unambiguous generic type arguments - Function Types:
fn(int, string) -> boolin parameter positions - Improved Error Messages: Better type inference failure diagnostics
- Type Checker Enhancements: Support for calling function-typed variables
- Unsafe Blocks:
unsafe { ... }for unsafe operations - Unsafe Functions:
unsafe fndeclarations - Raw Pointer Types:
*const Tand*mut Tfor low-level memory access - Full Syntax Support: Parser, type checker, and codegen integration
- C Runtime Library: 10 string utility functions
- String Operations: len, concat, substring, contains, starts_with, ends_with
- String Transformations: to_upper, to_lower, trim, replace
- File I/O: 9 functions (fseek, ftell, rewind, feof, ferror, fopen, fclose, fread, fwrite)
- Math Functions: 25 functions (trig, hyperbolic, exponential, log, power, rounding, etc.)
- Time Functions: 6 functions (time, clock, difftime, strftime, localtime)
- Memory Functions: 7 functions (calloc, aligned_alloc, realloc, free, memcpy, memset, memcmp)
- Union Keyword: Foundation for C interop union types
- Total: 57+ runtime library functions
- Bounds Checking: Runtime validation for array/slice/string indexing
- Memory Leak Detection: Track malloc/free pairs with detailed reporting
- Safety Helpers: Null pointer checking, allocation tracking, debugging utilities
- Environment Variables:
KRAKEN_BOUNDS_CHECK=1,KRAKEN_LEAK_CHECK=1 - Documentation: STRINGS.md guide with
string_processing.krandsafe_pointers.krexamples - Total: 11 new safety functions
- Collection Helper Functions: 15+ runtime functions for array operations, iterators, and utilities
- Array Operations: map, filter, fold, any, all, find
- Range Iterator: create, next, free for efficient iteration
- Utility Functions: clone, compare, hash, default, conversion helpers
- Documentation: 1,000+ line TRAITS.md guide with complete trait system specification
- Standard Traits: Clone, Copy, Debug, Display, Default, Drop specifications
- Operator Traits: Add, Sub, Mul, Div, comparison, bitwise, indexing, dereference
- Conversion Traits: From, Into, TryFrom, TryInto, AsRef, AsMut
- Iterator Traits: Iterator, IntoIterator with adapter methods
- Usage Examples: 400+ line
trait_patterns.krwith 14 examples - Total: 83+ runtime library functions
- AST Nodes: TraitDeclaration, TraitImpl, TraitMethod, AssociatedType
- Parser Support: Full trait syntax parsing (declarations, implementations, generic traits, trait inheritance)
- Trait Declarations:
trait Name { ... },trait Trait<T> { ... },trait Sub: Super { ... } - Trait Implementations:
impl Trait for Type { ... }, generic implementations, where clauses - Method Types: Required methods, provided methods (default implementations), async methods
- Associated Types: Full parser support for associated types in traits
- Compiler Integration: All passes updated (closure analysis, monomorphization, type checker, module loader)
- All Tests Passing: 105/105 tests passing with parser implementation
- Type Checking: Full type checking for trait declarations and implementations
- Validation: Super trait existence, method signature matching, required method checking
- Type Environment: TraitType and TraitImpl tracking in type environment
- Method Verification: Parameter type matching, return type matching, provided method type checking
- Orphan Rules: Coherence checking prevents duplicate trait implementations
- Monomorphization: Generic trait collection and trait bound support
- Standard Library Traits: 40+ trait definitions in
stdlib/traits.kr- Iterator traits: Iterator, IntoIterator
- Operator traits: Add, Sub, Mul, Div, Rem, Neg, BitAnd, BitOr, BitXor, Not, Shl, Shr
- Comparison traits: PartialEq, Eq, PartialOrd, Ord
- Conversion traits: From, Into, TryFrom, TryInto, AsRef, AsMut
- Standard traits: Display, Debug, Clone, Copy, Drop, Default, Hash
- Function traits: Fn, FnMut, FnOnce
- Dereference traits: Deref, DerefMut
- Indexing traits: Index, IndexMut
- Thread safety: Send, Sync
- Test Coverage: 4 test files covering all trait patterns
- All Tests Passing: 105/105 tests passing with complete trait system
- Trait Object Types:
dyn Traitsyntax with multiple bounds (dyn Trait + Send + Sync) - Vtable Generation: Vtable construction from
impl Trait for TypeusingLLVMConstArray2/LLVMConstBitCast - Fat Pointers:
{ data_ptr, vtable_ptr }fat pointer construction at assignment and parameter sites - Indirect Calls: Method dispatch through vtable slots via
LLVMBuildCall2 - Type Checker:
dyn Traittypes compatible with concrete struct types; method calls ondyn Traitobjects resolve return types from trait method signatures Selfcompatibility:Selftype in trait method declarations compatible with concrete types in trait impls
- Variadic Functions: Full support for variadic function calls (printf-style)
- Union Types:
unionkeyword with C-compatible layout; all compiler passes updated - Raw Pointer FFI:
*const T/*mut Tin function signatures and FFI declarations
- Async Functions: Transform async functions into future struct + poll function + state machine wrapper
- State Machines: Multi-state codegen splitting function bodies at
awaitpoints; locals saved and restored across suspension awaitExpressions: Polls sub-futures, extracts results, and resolves to the original declared return typeblock_onIntrinsic: Inline poll loop with no C runtime dependency- Type Checker: Async call sites return
Type::Bytes(future pointer);awaitresolves to the declared return type
- Windows UCRT Linker: Replaced
sprintfwithsnprintfinfmt_int,fmt_hex,fmt_floatcodegen —sprintfis not exported by Windows UCRT - LLVM API updates:
LLVMArrayType→LLVMArrayType2,LLVMConstArray→LLVMConstArray2in vtable construction - Module Loader:
TraitDeclaration,TraitObject,ImplBlock,TraitImpl, andType::Genericnames now mangled consistently across the module system
- Static Typing: Strong type system with type inference
- LLVM Backend: Efficient native code generation
- C FFI: Direct interop with C libraries
- Module System: Organized code with imports and visibility control
- Memory Safety: Ownership-based memory management (in development)
- compiler/ — Kraken compiler implementation
- runtime/ — Runtime library and C FFI bindings
- examples/ — Example programs
- tests/programs/ — Integration and stress test suite
- LLVM 18 (required to build the compiler via
llvm-sys) - Clang (used for linking)
- Rust 1.80+ (MSRV declared in
Cargo.toml)
See docs/platform.md for additional platform notes.
brew install llvm@18
# Point llvm-sys at the Homebrew LLVM install
export LLVM_SYS_180_PREFIX="$(brew --prefix llvm@18)"
# Make llvm-config available on PATH (recommended)
export PATH="${LLVM_SYS_180_PREFIX}/bin:${PATH}"
# Sanity check
llvm-config --versionwget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 18
sudo apt-get install -y libzstd-dev libpolly-18-dev clang-18 lld-18
export LLVM_SYS_180_PREFIX=/usr/lib/llvm-18choco install llvm --version=18.1.8 -y
$env:LLVM_SYS_180_PREFIX = "C:\Program Files\LLVM"
$env:Path = "$env:LLVM_SYS_180_PREFIX\bin;$env:Path"
llvm-config --versionIf you build LLVM yourself or use a different distribution, point LLVM_SYS_180_PREFIX at the install root (the directory containing bin/llvm-config).
The project includes a .envrc file that sets the LLVM environment variables automatically. Install direnv, hook it into your shell, then cd into the repo and direnv allow. After that, the variables load whenever you enter the directory.
Most IDEs don't pick up direnv on their own. If your IDE shows LLVM errors but source .envrc && cargo build works in a terminal, that's the cause.
cargo build -p krakencargo fmt --check
RUSTFLAGS="-D warnings" cargo test --workspace
RUSTFLAGS="-D warnings" cargo clippy --workspace --all-targets --all-featurescargo run -p kraken -- build examples/hello.kr
./build/hellofn main() -> int {
let point: (int, int) = (10, 20);
let (x, y) = point;
puts("Point coordinates:");
puts(x); // 10
puts(y); // 20
0;
}
fn classify(x: int) -> string {
match (x) {
0 -> { "zero" }
1 | 2 | 3 -> { "one, two, or three" }
_ if x < 0 -> { "negative" }
_ if x < 10 -> { "single digit" }
10..100 -> { "two digits" }
_ -> { "large number" }
}
}
fn factorial(n: int) -> int {
let result: int = 1;
for (i in 1..=n) {
result = result * i;
}
result;
}
fn main() -> int {
puts(factorial(5)); // 120
0;
}
fn safe_divide(a: int, b: int) -> int {
if (b == 0) {
return 0;
}
a / b;
}
fn main() -> int {
let result: int = safe_divide(10, 2);
puts(result); // 5
0;
}
Kraken now includes built-in container types with heap-allocated storage:
| Type | Description |
|---|---|
VecInt |
Dynamic array of int |
VecString |
Dynamic array of string |
VecBytes |
Dynamic array of bytes |
MapStringInt |
String-keyed map with int values |
MapStringString |
String-keyed map with string values |
See docs/CONTAINERS.md for full API reference and examples/vec_demo.kr, examples/map_demo.kr for usage examples.
string: currently lowered to ani8*and primarily used for C-string text at the libc/FFI boundary.bytes: currently lowered to ani8*and used for raw buffers and opaque handles (e.g.mallocpointers,FILE*-like values).- Indexing:
string[i]returns anintin the range0..255(byte indexing).bytes[i]returns anintin the range0..255(byte indexing).
- C-string helpers:
cstr(string) -> bytes: explicit boundary helper for passing text to APIs expecting ani8*.from_cstr(bytes) -> string: explicit boundary helper for treating ani8*as a C-string (traps on null).
Language Spec: See the Formal Grammar
Copyright © 2026
