Skip to content

Getting Started

This guide walks you through installing the Kōdo compiler and running your first program.

The quickest way to get started. Download from the Releases page:

Terminal window
# 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 kodoc
sudo 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:

Terminal window
kodoc --version

Prerequisites:

  • Rust toolchain (1.91 or later) — install via rustup
  • C linker (cc) — see above
Terminal window
git clone https://github.com/rfunix/kodo.git
cd kodo
make install

This builds in release mode and installs kodoc to ~/.kodo/bin/. Add to your PATH:

Terminal window
echo 'export PATH="$HOME/.kodo/bin:$PATH"' >> ~/.zshrc # or ~/.bashrc
source ~/.zshrc

Verify:

Terminal window
kodoc --version

Tip: You can also use make install PREFIX=/usr/local to install system-wide.

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.

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:

  1. A module declaration with a name
  2. A meta block describing the module’s purpose, version, and author
  3. A main function as the entry point
Terminal window
kodoc build hello.ko -o hello
./hello

You should see:

Successfully compiled `hello` → hello
Hello, World!

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:

Terminal window
kodoc build fibonacci.ko -o fibonacci
./fibonacci

This prints 55 — the 10th Fibonacci number.

You can type-check and verify contracts without generating a binary:

Terminal window
kodoc check hello.ko

This is useful for fast feedback during development.