Sakura Lang

Quickstart

Install Sakura Lang, then create, run and test a first program in about two minutes.

This page takes you from nothing to a running program. It takes about two minutes.

1. Install

You need Node 26: sakura run and sakura test run the compiled JavaScript with node. Then install the compiler with npm:

npm install --global sakuralang
sakura --version

On macOS or Linux x64 you can use Homebrew instead:

brew tap icantcodefyi/sakuralang
brew trust --tap icantcodefyi/sakuralang
brew install sakuralang

Install covers Windows, the installer script, other versions and every platform.

2. Create a project

sakura new cli hello
cd hello

This makes a hello folder with a manifest (sakura.toml), your code in src/main.sak, and an AGENTS.md that tells coding agents how to work in the project.

3. Run it

sakura run
hello, world

Anything after -- goes to your program:

sakura run -- Ada
hello, Ada

4. Read the code

Open src/main.sak:

hello/src/main.sak
import std/cli.{Cli}

/// The greeting for `name`.
pub fn greeting(name: String) -> String { "hello, {name}" }

pub fn main() -> Unit ! {Cli, Console} {
  let name = Option.unwrap_or(List.first(Cli.args()), "world")
  Console.print(greeting(name))
}

test "greets by name" { expect_eq(greeting("Sakura Lang"), "hello, Sakura Lang") }

Open in playground

  • greeting has no ! in its signature, so it is pure: it only builds a string.
  • main ends with ! {Cli, Console}. These are its effects, the things it does besides returning a value. It reads command-line arguments (Cli) and prints (Console), and nothing else.
  • List.first returns an Option: Some(first) or None for an empty list. There is no null. Option.unwrap_or picks "world" when there is no argument.
  • The test sits next to the code it tests.

5. Test and check

sakura test
test greets by name ... ok

1 passed, 0 failed, 0 skipped (seed 0)

Tests run with a fixed clock, seeded randomness and captured output, so they give the same result every time. sakura check type-checks the project without running it:

sakura check
no problems

6. Break it on purpose

Make greeting print, without changing its signature:

hello/src/main.sak
import std/cli.{Cli}

/// The greeting for `name`.
pub fn greeting(name: String) -> String {
  Console.print("greeting {name}")
  "hello, {name}"
}

pub fn main() -> Unit ! {Cli, Console} {
  let name = Option.unwrap_or(List.first(Cli.args()), "world")
  Console.print(greeting(name))
}

Open in playground

sakura check refuses it:

error[V3001]: function `greeting` performs `Console`, which its signature does not allow (allowed: `{}`)
  ┌─ src/main.sak:4:8
  │
4 │ pub fn greeting(name: String) -> String {
  │        ^^^^^^^^
5 │   Console.print("greeting {name}")
  │   -------------------------------- `Console.print` performs `Console` here
  │
  = expected: {}
  =    found: {Console}
  = help: Add `Console` to the signature
  = help: Handle the effect locally with `with`
  = see `sakura explain V3001`

1 error

The signature promised a pure function, and the body broke that promise. You have two honest fixes: add ! {Console} to the signature, so a reviewer sees the change, or remove the print. sakura explain V3001 describes the error with a wrong and a fixed program.

Agents read the same error as JSON with sakura check --json. See Diagnostics.

7. Ask the compiler what fits

A typed hole is a placeholder, ?name, for code you have not written yet. sakura check accepts it and tells you what could go there:

fn unfinished(x: Int) -> Int { ?result }
hole ?result: expected Int, effects {}; locals [x: Int]; candidates [x, Int.abs(?i), Int.clamp(?i, ?lo, ?hi), …]

sakura build and sakura run refuse a program that still has holes. See Typed holes.

What is in the project

  • sakura.toml names the package. Its [permissions] table lists what the program may reach: files, network hosts and environment variables. It starts empty, because this program only reads its arguments and prints. See sakura.toml.
  • src/ holds the code. One file is one module, and src/main.sak holds main.
  • AGENTS.md and CLAUDE.md give coding agents short instructions: run check, fmt --check and test, and never weaken a contract to make a check pass.

Format your code with sakura fmt. It has no options, so every project looks the same.

Common commands

CommandWhat it does
sakura new cli NAMECreate a project (lib, agent and api also exist)
sakura run [-- ARGS]Build and run main
sakura testRun every test and property
sakura checkType-check without running
sakura fmtFormat the code
sakura explain CODEExplain an error code
sakura build --target wasmBuild for WebAssembly instead of JavaScript

The CLI reference lists every command, flag and exit code.

Install from source

To follow main between releases, build the compiler yourself. You need rustup and Node 26. rustup fetches the pinned Rust version on the first build.

git clone https://github.com/icantcodefyi/sakuralang
cd sakuralang/compiler
cargo install --locked --path crates/sakura_cli
sakura --version

From a checkout, sakura run compiler/examples/counter runs one of the example projects.

Next

Start the Language Tour, or build and deploy a server.

Edit on GitHub

Last updated

On this page