Getting Started
This guide walks you through installing the Kōdo compiler and running your first program.
Installation
Section titled “Installation”Option A: Download Pre-Built Binary
Section titled “Option A: Download Pre-Built Binary”The quickest way to get started. Download from the Releases page:
# macOS (Apple Silicon)curl -L https://github.com/rfunix/kodo/releases/latest/download/kodoc-macos-aarch64 -o kodoc
# macOS (Intel)curl -L https://github.com/rfunix/kodo/releases/latest/download/kodoc-macos-x86_64 -o kodoc
# Linux (x86_64)curl -L https://github.com/rfunix/kodo/releases/latest/download/kodoc-linux-x86_64 -o kodoc
chmod +x kodocsudo mv kodoc /usr/local/bin/Requirement: A C linker (cc) is needed to link the final executable:
- macOS: Install Xcode Command Line Tools (
xcode-select --install) - Linux: Install
build-essential(sudo apt install build-essential)
Verify:
kodoc --versionOption B: Build from Source
Section titled “Option B: Build from Source”Prerequisites:
- Rust toolchain (1.91 or later) — install via rustup
- C linker (
cc) — see above
git clone https://github.com/rfunix/kodo.gitcd kodomake installThis builds in release mode and installs kodoc to ~/.kodo/bin/. Add to your PATH:
echo 'export PATH="$HOME/.kodo/bin:$PATH"' >> ~/.zshrc # or ~/.bashrcsource ~/.zshrcVerify:
kodoc --versionTip: You can also use
make install PREFIX=/usr/localto install system-wide.
Optional: Z3 for Static Verification
Section titled “Optional: Z3 for Static Verification”To enable compile-time contract verification via Z3:
- macOS:
brew install z3 - Ubuntu/Debian:
sudo apt-get install libz3-dev
Then rebuild with cargo build -p kodoc --release --features smt. See the Contracts guide for details.
Your First Program
Section titled “Your First Program”Create a file called hello.ko:
module hello { meta { purpose: "My first Kōdo program", version: "0.1.0", author: "Your Name" }
fn main() { println("Hello, World!") }}Every Kōdo program has:
- A module declaration with a name
- A meta block describing the module’s purpose, version, and author
- A
mainfunction as the entry point
Compile and Run
Section titled “Compile and Run”kodoc build hello.ko -o hello./helloYou should see:
Successfully compiled `hello` → helloHello, World!A More Interesting Example
Section titled “A More Interesting Example”Let’s write a program that computes Fibonacci numbers:
module fibonacci { meta { purpose: "Compute Fibonacci numbers", version: "0.1.0", author: "Your Name" }
fn fib(n: Int) -> Int { if n <= 1 { return n } return fib(n - 1) + fib(n - 2) }
fn main() { let result: Int = fib(10) print_int(result) }}Compile and run:
kodoc build fibonacci.ko -o fibonacci./fibonacciThis prints 55 — the 10th Fibonacci number.
Checking Without Compiling
Section titled “Checking Without Compiling”You can type-check and verify contracts without generating a binary:
kodoc check hello.koThis is useful for fast feedback during development.
Next Steps
Section titled “Next Steps”- A Tour of Kōdo — a quick walkthrough of all language features
- Language Basics — types, variables, and control flow
- Data Types and Pattern Matching — structs, enums, and
match - Contracts — runtime preconditions and postconditions
- CLI Reference — all available commands and flags