burn / docs

Burn

A small, statically typed language with smart casts that runs instantly on its own virtual machine and compiles to native code.

Burn is a general purpose programming language with a clean syntax, static types that you rarely have to write, and smart casts that follow your if checks. Burn is written in Burn: the compiler, its tools, the runtime and bvm, the Burn virtual machine with its JIT, are Burn programs compiled to native code.

curl -fsSL https://raw.githubusercontent.com/burnlang/burnup/master/install.sh | sh

Get started Take the syntax tour

def interface Shape {
    fun area(): float
}

def struct Circle(radius: float) :: Shape {
    fun area(): float {
        return 3.14159 * radius * radius
    }
}

fun describe(value: any): string {
    if (value is Shape) {
        return "a shape with area ${value.area()}"
    }
    return "something else"
}

print(describe(new Circle(2)))

The documentation

Language

The language itself: variables and types, functions and closures, match, structs and enums, generics, null safety, modules, async and inline assembly.

Standard library

What ships with Burn: the built-in functions and the modules for math, strings, files, processes, JSON, HTTP and time.

Tools

Working with Burn: the command line, projects and packages, tests, the REPL, the formatter, editors and native builds.

How Burn works

What happens in the background, from the parser and type checker to values in memory, reference counting and bvm.

The Burn VM

The Burn Virtual Machine on its own: its assembly language, instructions, linking, archives, mixins and embedding.

Ways to run the same program

Command What happens Typical use
burni app.bn compiled to a bvm module in memory and run right away, starts in milliseconds development, scripts
burnc app.bn compiled to x86-64 or arm64 assembly and linked into a standalone executable shipping
burnc app.bn --target bvm compiled to a portable .bvmc bytecode file, run with burn or bvm distributing without a build per platform
burnc app.bn --target bar the program and its bytecode libraries in one runnable .bar archive shipping applications that run everywhere bvm runs
burnc app.bn --target js compiled to a JavaScript file that runs with Node.js running where Node.js is already installed

All backends share the same type checker and runtime library (the JavaScript build carries a runtime written in JavaScript that matches it), so a program behaves the same way everywhere.

The virtual machine, bvm, is not tied to Burn: it has its own assembly language, bytecode format, verifier, JIT and API, and other languages can compile to it.