Pre-release · download the latest build

A small, statically typed scripting language.

Coil gives you real type inference, algebraic data types and pattern matching, coroutines and FFI — compiled to compact bytecode and run on a thin, embeddable VM.

Source
.hy
Bytecode
.hyc
CLI
coil
Packages
spool
shapes.hy
use io::{stdout};
use io::sync::{write_all};
use string::{format, to_bytes};

enum Shape {
    Circle(int),
    Rect { width: int, height: int },
}

fn area(Shape s) -> int {
    return match s {
        Shape::Circle(r) => 3 * r * r,
        Shape::Rect { width, height } => width * height,
    };
}

fn main() {
    let shapes = [
        Shape::Circle(3),
        Shape::Rect { width: 3, height: 4 },
    ];
    for s in shapes {
        write_all(stdout(), to_bytes(format("%i\n", area(s))));
    }
}
$ coil shapes.hy
27
12
The language

More structure than a script. Less ceremony than a systems language.

Every feature below links to the tutorial chapter that teaches it.

How it runs

From source to bytecode, once.

The CLI caches the compiled archive and reuses it until sources, version or entry point change — so the second run starts straight on the VM.

  1. 01 Parse Pratt parser → AST .hy
  2. 02 Typecheck Hindley–Milner inference
  3. 03 Codegen Stack IL, lowered & fused
  4. 04 Archive Versioned bytecode .hyc
  5. 05 Run Thin VM executes main

One command for the whole loop

Build, test, format, package and serve the language server from the same coil binary. Dependencies are fetched by spool.

Install and run your first program →
  • $ coil app.hy Compile (cached) and run
  • $ coil test Run test blocks under ./tests
  • $ coil fmt src/ Format sources in place
  • $ coil package app.hy Build a single executable
  • $ coil lsp Language server for your editor
Documentation

Two ways in.

Follow the tutorial from the first line of code, or jump straight to the reference when you need an exact answer.

Ecosystem

Small core, userland packages.

The compiler ships the essentials as virtual modules. Everything else lives in ordinary Coil packages — starting with coil-stdlib.

Write your first .hy file.

Grab the toolkit from GitHub Releases — or, until the first tagged release, the latest release-binaries build.

↑ ↓ navigate ↵ open