Steel Documentation

Reference for installing Steel, writing code, organizing multi-file projects, and compiling to C, C++, Rust, Go, Python, JavaScript, TypeScript, and Lua.

No documentation sections matched your filter. Try a different keyword such as compile, class, or bundle.

Getting Started

You can install Steel on Windows using the graphical setup wizard or build it directly from source using Rust and Cargo.

Option 1: Windows Installer

Download the release ZIP from GitHub, extract it, and run steel-setup.exe. The installer copies steel.exe to %USERPROFILE%\.steel\bin, adds it to your system PATH, and installs the VS Code extension for syntax highlighting and live diagnostics.

Option 2: Build from Source

Shell
git clone https://github.com/yourusername/steel.git
cd steel
cargo build --release

Verify your installation and run your first file:

Shell
steel --version
steel init hello-steel
cd hello-steel
steel run

Language Basics

Steel uses C-style curly braces { ... } with optional semicolons. The let keyword is optional — assigning name = "Steel" automatically creates the variable, while let and const remain supported whenever you want explicit declarations or constants.

basics.steel
// `let` and semicolons are both optional
name = "Steel"
const version: num = 1.0
active = true
nothing = null

// String interpolation uses ${...}
print("Running ${name} v${version}")

Built-in Types

  • num — 64-bit floating-point numbers (integers and decimals)
  • str — UTF-8 strings with ${expr} interpolation
  • bool — true or false
  • null — absence of a value
  • array — dynamic ordered list [1, 2, 3]
  • map — key-value object { x: 10, y: 20 }

Control Flow & Loops

Conditions do not require parentheses around the expression. Ranges use start..end (exclusive of end).

control_flow.steel
let hp = 45

if hp <= 0 {
    print("Defeated")
} else if hp < 50 {
    print("Low health")
} else {
    print("Healthy")
}

// Range loop (0, 1, 2, 3, 4)
for i in 0..5 {
    print("Step", i)
}

// While loop
let count = 3
while count > 0 {
    count -= 1
}

// Ternary expression and null coalescing
let label = hp > 0 ? "Alive" : "Out"
let fallback = null ?? "default"

Functions, Lambdas & Pipes

Functions are declared with fn and support short one-line definitions (fn double(x) = x * 2), default parameter values, optional type annotations, arrow lambdas (x => x * 2), and the pipe operator (|>) for readable left-to-right data flow.

functions.steel
// Short one-line functions (and class methods!)
fn double(x) = x * 2
fn add(a, b = 10) = a + b

// Pipe operator passes the left result into the next function
score = 5 |> double |> add
print("Score:", score) // 20

// Arrow lambdas with array methods
nums = [1, 2, 3, 4, 5, 6]
evens_sq = nums.filter(x => x % 2 == 0).map(x => x ** 2)
print(evens_sq) // [4, 16, 36]

Arrays, Maps & Classes

Steel supports object-oriented classes with init constructors, methods, and this references. When compiling to C, Rust, Go, or Lua, classes are automatically lowered into clean factory functions and method maps.

classes.steel
class Player {
    init(name, hp = 100) {
        this.name = name
        this.hp = hp
    }

    damage(amount) {
        this.hp -= amount
        return this.hp
    }
}

let hero = new Player("Alex", 120)
print(hero.name, "HP:", hero.damage(25))

Multi-File Projects & Imports

Split larger programs into multiple .steel files and pull them in with import.

main.steel
import "map.steel"
import "raycaster.steel"

let cell = get_cell(2, 3)
print("Map cell:", cell)
Default behavior: Compiling a directory or a file with imports keeps every module as a separate file in <project>_<target>/ (for example, steel3d_c/map.h, map.c, raycaster.h, raycaster.c, and main.c).
Separate files (default) vs single combined file
# Default: emits separate C11 files in projects/steel3d_c/
steel compile projects/steel3d c

# Combine all modules into one standalone file (projects/steel3d.c)
steel compile projects/steel3d c --bundle

Compilation Targets

Pass any of the 8 supported targets to steel compile, or pass all to generate output for every language at once.

Examples
steel compile app.steel c
steel compile app.steel cpp
steel compile app.steel rust --bin --release
steel compile app.steel go
steel compile app.steel python
steel compile app.steel js
steel compile app.steel ts
steel compile app.steel lua
steel compile app.steel all

For C11 and Rust, Steel's static type analyzer checks whether all variables and functions resolve to concrete types. When they do, it emits direct native types (double, const char*, f64) with zero runtime wrapper code.

CLI Reference

Command Description
steel Launch the interactive REPL (supports :target and :visual).
steel run <file|dir> Execute a Steel file or project directory immediately.
steel compile <path> <lang> Compile a file or directory to the chosen target language.
steel check <file> Run syntax, undefined-variable, and type checks without executing.
steel test <file> Run all test "name" { ... } blocks in a file.
steel watch <file> Re-run automatically whenever the file is saved.
steel bench <file> Benchmark optimization, bytecode compilation, VM speed, and C11 codegen.
steel vm <file> --run Compile to Steel stack-VM bytecode and execute it.
steel fmt <file> Format Steel source code cleanly.
steel doc <file> Generate Markdown API documentation from inferred types and functions.
steel init <name> Scaffold a new project with steel.toml, src/main.steel, and tests.

Common Compile Flags

  • --bundle / --single — Combine multi-file projects into one output file.
  • --bin / -b — Compile C, C++, Rust, or Go output all the way to a native executable.
  • --release / -O — Enable maximum compiler optimizations (-O3 / opt-level=3).
  • --visual / -v — Show live 5-stage compiler morphing in the terminal.
  • --out <path> / -o — Choose a custom output file or directory path.
  • --force / -f — Overwrite existing output files without warnings.
  • --stdout / -p — Print generated code directly to stdout.

Standard Library

Steel includes over 55 built-in functions available without extra imports:

  • Math: abs, sqrt, floor, ceil, round, min, max, sin, cos, tan, pow, random, PI, E
  • Strings: upper, lower, trim, split, join, replace, contains, starts_with, ends_with, len
  • Arrays: push, pop, map, filter, reduce, sum, avg, unique, zip, sort, reverse, range
  • Files & System: read_file, write_file, file_exists, env, args, exec, time_ms, sleep
  • Data & Crypto: json_parse, json_stringify, hash (FNV-1a), uuid, assert

How the Rust Compiler Works

Steel is implemented in Rust with a clean, modular pipeline under src/. Each stage transforms the program into a higher-level or lower-level representation:

  • src/lexer.rs — Scans raw text into tokens with line and column spans.
  • src/parser.rs — Recursive-descent parser producing the AST defined in src/ast.rs.
  • src/typecheck.rs — Infers variable and function types and catches undefined symbols.
  • src/optimizer.rs — Constant folding and algebraic simplification pass.
  • src/interp.rs & src/vm.rs — Tree-walking interpreter and bytecode stack VM.
  • src/codegen.rs — Multi-target transpiler emitting single-file or multi-file projects for all 8 languages.