Hello World & the Toolchain

Create hello.hl: Compile and execute it in one step with hale run: To produce a standalone native binary on disk, use hale build:

1. Hello World

Section titled “1. Hello World”

Create hello.hl:

fn main() {
let name = "Hale";
println("Hello from ", name, ".");
}

Compile and execute it in one step with hale run:

Terminal window
hale run hello.hl
Hello from Hale.

To produce a standalone native binary on disk, use hale build:

Terminal window
hale build hello.hl
./hello

hale run and hale build use the exact same LLVM compiler pipeline—there is no separate interpreter. hale run compiles to a temporary binary, executes it, and cleans it up.

Scaffold a New Project

Section titled “Scaffold a New Project”

To start a multi-file project with a hale.toml manifest, an entry seed, and a test file:

Terminal window
hale init my-app
cd my-app
hale run .
hale test .

Passing a directory (hale run ., hale check ., hale build .) compiles all .hl files in that directory as a single seed (package/module unit) with shared top-level scope.


2. Basic Syntax Rules

Section titled “2. Basic Syntax Rules”

3. Essential Toolchain Commands

Section titled “3. Essential Toolchain Commands”
Command Description
hale check <file|dir> Parse, typecheck, and run static topology/effect/memory analyses without codegen
hale verify <file|dir> Strict CI gate: runs hale check and fails on any warning or advisory
hale run <file|dir> [args...] Compile and immediately execute
hale build <file|dir> [-o <out>] Compile to a native binary (or .wasm + .mjs with --target wasm32)
hale test <file|dir> Compile and run *_test.hl test suites
hale bench <file|dir> Compile and run *_bench.hl benchmarks (ns/op, allocs/op)
hale fmt <file|dir> Format source code in place (zero-config, 100-column structural line breaking)
hale doc [<file|dir> | --stdlib] Render documentation from /// comments or inspect the standard library (--stdlib)
hale lsp Start the built-in Language Server Protocol (LSP) server over stdio
hale mcp [--app <endpoint>] Start the Model Context Protocol (MCP) server for AI agents

4. Build Modes, Tracing & Debugging

Section titled “4. Build Modes, Tracing & Debugging”

Fast Iteration (--dev)

Section titled “Fast Iteration (--dev)”

By default, hale build and hale run compile with -O3 tuned for the host CPU (--target-cpu portable builds a binary that runs on other machines of the same architecture too: use it for anything you ship, such as a container image; hale build warns when it sees a container build or CI without it). During rapid edit-compile-run loops, enable the lighter optimization pipeline:

Terminal window
hale build --dev app.hl
# or via environment variable:
HALE_DEV=1 hale run app.hl

Build Timing & Lifecycle Tracing

Section titled “Build Timing & Lifecycle Tracing”
Environment Variable Effect
HALE_TIME=1 Prints per-phase compiler wall times during hale build / hale run.
HALE_LIFECYCLE_TRACE=1 Instruments the binary to log every locus birth, run, drain, dissolve, reclaim, and pool join to stderr with instance IDs, restart incarnations, and thread IDs.
LOTUS_NO_DEBUGINFO=1 Omits DWARF debug symbols from the emitted binary.

Native Debugging with gdb / lldb

Section titled “Native Debugging with gdb / lldb”

Compiled binaries include full DWARF debug info by default at zero runtime cost:


5. Editor Integration (hale lsp & --json)

Section titled “5. Editor Integration (hale lsp & --json)”

Language Server (hale lsp)

Section titled “Language Server (hale lsp)”

Point any LSP-compatible editor (VS Code, Neovim, Helix, Zed, Emacs) at hale lsp. It requires zero configuration and provides:

Machine-Readable Diagnostics (--json)

Section titled “Machine-Readable Diagnostics (--json)”

For scripts, save hooks, or custom tooling, pass --json to hale check:

Terminal window
hale check app.hl --json

This emits one NDJSON object per diagnostic (file, line, col, severity, kind, message) on stdout. An empty output stream guarantees a clean check.

Next: Your First Program.