burn / docs

Introduction

Getting started

Install

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

This installs the whole toolchain into ~/.burn/bin: burni (interpreter), burnc (compiler), burnfmt (formatter), burn-lsp (language server), ash (package manager) and burn, which combines them all. Building from source needs a C compiler, tar and xz, and native executables need a C toolchain (cc). See installation for options and other platforms.

Hello world

print("Hello, World!")
burni hello.bn

Top level statements run from top to bottom. If the file defines fun main(), it is called after the top level code.

A slightly bigger program

def type Todo {
    string title
    bool done = false
}

fun summary(todos: [Todo]): string {
    var open = 0
    for t in todos {
        if (!t.done) {
            open += 1
        }
    }
    return "${open} of ${len(todos)} still open"
}

fun main() {
    var todos = [Todo { title: "write docs" }, Todo { title: "ship", done: true }]
    print(summary(todos))
}

Build it

burnc todo.bn              # produces ./todo, a native executable
./todo
burnc todo.bn --target bar # produces todo.bar, one archive with everything the program needs
./todo.bar

The executable is small (a few hundred kilobytes) and does not need Burn to be installed. Bytecode (--target bvm) and archives run wherever bvm runs, on any platform.

Try things in the REPL

$ burni
>>> var names = ["ada", "grace"]
>>> names.length
2
>>> fun shout(s: string): string {
...     return upper(s) + "!"
... }
>>> shout(names[1])
GRACE!

Format your code

burnfmt -w todo.bn

Start a project

Once a program grows past one file, make it a project. The name says where the code will live:

burn init github.com/you/todo
cd todo
burn run
ash install github.com/you/colors    # add a package

See projects and packages.

Next steps