Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions content/getting-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ curl -fsSL https://raw.githubusercontent.com/burnlang/burnup/master/install.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 Rust
1.85 or newer for bvm, and native executables need a C toolchain (`cc`). See [installation](./tooling/installation.mdx)
(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](./tooling/installation.mdx)
for options and other platforms.

## Hello world
Expand Down
8 changes: 4 additions & 4 deletions content/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ order: 0
# Burn

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. The compiler and its tools are written in Burn and run on bvm, the Burn
virtual machine, which is written in Rust.
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.

```burn
def interface Shape {
Expand Down Expand Up @@ -47,7 +47,7 @@ All backends share the same type checker and runtime library (the JavaScript bui
JavaScript that matches it), so a program behaves the same way everywhere.

The virtual machine, [bvm](./bvm/overview.mdx), is not tied to Burn: it has its own assembly language, bytecode
format, verifier and Rust API, and other languages can compile to it.
format, verifier, JIT and API, and other languages can compile to it.

## Where to go next

Expand Down Expand Up @@ -107,5 +107,5 @@ format, verifier and Rust API, and other languages can compile to it.
- [Burn archives (.bar)](./bvm/archives.mdx)
- [Mixins](./bvm/mixins.mdx)
- [Native interop](./bvm/native-interop.mdx)
- [Optimizing while running](./bvm/optimizing.mdx)
- [The JIT](./bvm/optimizing.mdx)
- [Migrating from the Go version](./migration.mdx)
2 changes: 1 addition & 1 deletion content/language/calling-c.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,4 @@ loads the arguments into the registers the C calling convention uses (`rdi`, `rs
call, it writes the opposite: code that saves the registers C expects to keep, pushes C's register arguments in
Burn's order and calls the Burn function.

The rest of Burn uses the same mechanism to move its own runtime and bvm from Rust to Burn.
Burn uses the same mechanism for its own runtime and bvm, which are written in Burn and call the C library this way.
6 changes: 3 additions & 3 deletions content/migration.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Migrating from the Go version
description: What changed in the Rust rewrite and how to update existing code.
description: What changed since the Go version and how to update existing code.
order: 66
---

Expand All @@ -10,7 +10,7 @@ order: 66
| --- | --- |
| `type Person { ... }` | `def type Person { ... }` |
| `class Human { fun create(...) ... }` | `def struct Human(...) { ... static fun create(...) ... }` |
| interpreter written in Go | compiler written in Rust and x86-64 assembly |
| interpreter written in Go | compiler, bvm and runtime written in Burn, native code for x86-64 and arm64 |
| `burn -exe file.bn` embedded the source in a Go program | `burn build file.bn` produces real machine code |
| every number was a float | `int` and `float` are separate types |
| `toString(x)` needed for `"a" + x` | `"a" + x` converts automatically |
Expand Down Expand Up @@ -42,7 +42,7 @@ print(Human.greet(john))

## Classes to structs

Earlier versions of the Rust rewrite had `def class`. Classes were replaced by
Earlier versions of the rewrite had `def class`. Classes were replaced by
[structs](./language/structs-and-interfaces.mdx), and `def class` is now a compile error ("classes are now
structs"). To update a class:

Expand Down
5 changes: 3 additions & 2 deletions content/standards.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Burn itself and the toolchain released with it (the compiler, the standard libra
`YY.RELEASE.PATCH`.

```text
26.1.0-experimental-6
26.1.0-experimental-7
│ │ │ └─────┬──────┘
│ │ │ pre-release
│ │ └── patch: fixes to that release
Expand All @@ -75,7 +75,7 @@ Burn itself and the toolchain released with it (the compiler, the standard libra
again at release `1`: `27.1.0`.
- **The second number counts the releases of that year**, and the third the fixes to one release: `26.1.2` is the
second fix of the first release of 2026.
- **Pre-releases end in `-experimental-N`**, counting up from `1`, before the release is final: `26.1.0-experimental-6`
- **Pre-releases end in `-experimental-N`**, counting up from `1`, before the release is final: `26.1.0-experimental-7`
comes before `26.1.0`.
- `burnup` also accepts short forms such as `26.1` and `^26.1`; see [installation](./tooling/installation.mdx).
- Packages that move with the year, such as bindings that follow Burn's releases, can use yearly versions too.
Expand All @@ -94,6 +94,7 @@ Every release of Burn is tagged `v<version>` and listed in the
| `26.1.0-experimental-4` | `v26.1.0-experimental-4` | native executables and JavaScript are back, generated by the compiler written in Burn |
| `26.1.0-experimental-5` | `v26.1.0-experimental-5` | low-level code: [`unsafe`](./language/unsafe.mdx), [inline assembly](./language/inline-assembly.mdx) for every target and raw memory with [`std/memory`](./stdlib/memory.mdx); native executables for arm64; Burn builds itself from the boot compiler in its repository, so building it only needs Rust |
| `26.1.0-experimental-6` | `v26.1.0-experimental-6` | modules: [import aliases](./language/modules.mdx#import-aliases) (`import "std/memory" as Mem`) and [imports inside functions and blocks](./language/modules.mdx#imports-inside-functions-and-blocks) |
| `26.1.0-experimental-7` | `v26.1.0-experimental-7` | no Rust: bvm and the runtime are written in Burn, the toolchain is one native executable, and Burn builds from assembly seeds with only a C compiler; [calling C](./language/calling-c.mdx) with `@Extern` |
| `26.1.0` | `v26.1.0` | the first stable release of 2026, after the experimental ones |
| `26.2.0`, `26.3.0`, … | `v26.2.0`, … | the next releases of 2026; fixes to a release are `26.1.1`, `26.1.2`, … |
| `27.1.0` | `v27.1.0` | the first release of 2027 |
Expand Down
4 changes: 3 additions & 1 deletion content/tooling/cli.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ The older flags still work: `-r`, `-e`, `-exe <file>` and `-d`.
| `BURN_PLATFORM` | build native executables for another platform: `linux-x86_64`, `macos-x86_64`, `linux-aarch64` or `macos-aarch64` ([cross-compiling](./cross-compiling.mdx)) |
| `BURN_RUNTIME_DIR` | the folder with the runtime native executables link against (default `share/burn/lib`) |
| `NO_COLOR` | disable colored diagnostics |
| `BURN_CLI_BVM` | the command line module bvm runs when it is started as `burn`, `burni`, `burnc` or `burn-lsp` (default `share/burn/burn.bvm` next to its `bin/`) |
| `BURN_JIT` | `0` turns bvm's [JIT](../bvm/optimizing.mdx) off, so everything is interpreted |
| `BURN_JIT_THRESHOLD` | how many calls or loop turns make a function hot enough for the JIT (default 1000) |
| `BURN_SYMBOLS` | `1` names every function in the assembly of native builds, for debuggers and profilers |
| `BURN_HOME` | where packages are found (default `~/.burn`, packages in `packages/`) |
| `BURN_GC_THRESHOLD` | bytes allocated between two searches for unreachable cycles (default 32 MB) |
| `BURN_GC_STATS` | print a line after every cycle search |
Expand Down
38 changes: 21 additions & 17 deletions content/tooling/compiler.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ knows the static type of its arguments.
## Runtime

All values are 64 bit words. Ints, floats, bools and enums are stored directly, everything else is a pointer to a
heap object with a 16 byte header (kind, flags, type id, size). The runtime core is part of bvm and written in
Rust (`bvm/runtime`): memory and reference counting with a cycle collector, strings, arrays, maps, boxing for
`any`, formatting, HTTP, files and async tasks. The functions built on top of it, such as `split`, `trim` or
`parseJSON`, are written in Burn (`lib/runtime`), compiled to a bvm module that bvm links into every program.
heap object with a 16 byte header (kind, flags, type id, size). The runtime is written in Burn (`lib/rt`): memory
and reference counting with a cycle collector, strings, arrays, maps, boxing for `any`, formatting, JSON, HTTP, files
and async tasks. It calls the C library through `@Extern`, is compiled into the toolchain for bvm, and is linked into
native executables as `libburn_runtime.a`.

## Ownership

Expand All @@ -49,8 +49,9 @@ computed once from the type graph.
general-purpose stack VM with its own assembly language, bytecode format and verifier. Burn structs become
`struct` types, interface methods become dispatch tables, `async` calls become `spawn`, and every operation that
can fail carries its source location. When the module is loaded, the verifier computes each function's frame
size and common sequences are fused into superinstructions for loops, comparisons and field access. Checking and
compiling a typical program takes a few milliseconds, so running a file feels like using an interpreter.
size and common sequences are fused into superinstructions for loops, comparisons and field access; functions that
run often are compiled to machine code by [the JIT](../bvm/optimizing.mdx). Checking and compiling a typical program
takes a few milliseconds, so running a file feels like using an interpreter.
`burnc --target bvm` writes the same module to a `.bvmc` file, and `--target bar` into an archive.

## Native code
Expand All @@ -61,26 +62,29 @@ expressions evaluate into `rax` or `x0`, comparisons in conditions become compar
access are inlined, and interface calls go through per-method dispatch tables. Both generators share the data layout,
the order of arguments on the stack and the code that decides what a native program exports
(`compiler/src/native/shared.bn`), so the same runtime serves both. The program entry point and the
trampoline that starts async tasks are hand-written assembly. The assembly is linked by `cc` with a static build of
the runtime (bvm and its runtime core, compiled by `scripts/native-runtime.sh` into `share/burn/lib`), so the result
is a standalone executable. A program that imports bytecode libraries embeds them, and bvm runs them inside the
executable.
trampoline that starts async tasks are generated assembly. The assembly is linked by `cc` with the runtime
(`libburn_runtime.a`, built by `scripts/native-runtime.sh` into `share/burn/lib`), so the result is a standalone
executable. A program that imports bytecode libraries is compiled to bytecode instead and linked with bvm
(`libburn_launcher.a`), which runs it inside the executable.

`--target js` turns the IR into one JavaScript file instead (`compiler/src/js/js.bn`), with a runtime written in
JavaScript in front of it (`lib/js/prelude.js`): every function becomes a JavaScript function, records become arrays
tagged with their type, and checked operations call small helpers that report the same runtime errors as bvm.

## Without the standard library

Programs built with `--no-std` or `std = false` link only the built-in core of the runtime (`libburn_core.a`, the
runtime core built without `std`), and the checker rejects the features it leaves out ([details](./no-std.mdx)).
Programs built with `--no-std` or `std = false` cannot import the standard library, and the checker rejects the
features it leaves out ([details](./no-std.mdx)).

## Bootstrapping

The compiler builds itself. bvm runs the boot compiler kept in the repository (`compiler/boot/compiler.bvmc`, a
compiled copy of the compiler), which compiles `compiler/src` once; that compiler builds itself again, and both
results must be the same module (`scripts/bootstrap.sh`). Building needs only Rust, for bvm; until
`26.1.0-experimental-4` a released Burn (stage0) started the bootstrap instead. Releases up to
The compiler builds itself. The C compiler assembles the seed kept in the repository (`compiler/boot/<platform>.tar.xz`,
the compiler as assembly), which compiles `compiler/src` once; that compiler builds itself again, and both results
must be the same assembly (`scripts/bootstrap.sh`). Building needs only a C compiler, tar and xz
([details](../internals/toolchain.mdx#how-the-compiler-builds-itself)). Until `26.1.0-experimental-4` a released Burn
(stage0) started the bootstrap, and until `26.1.0-experimental-7` a bytecode copy of the compiler run by the bvm
written in Rust. Releases up to
`26.1.0-experimental-2` were compiled by a compiler written in Rust; it was retired once the compiler written in Burn
did everything it did. `26.1.0-experimental-3` shipped without the native and JavaScript backends, and
`26.1.0-experimental-4` brings both back, ported to Burn.
`26.1.0-experimental-4` brings both back, ported to Burn. Since `26.1.0-experimental-7` bvm and the runtime are
written in Burn too, and no Rust is left.
22 changes: 11 additions & 11 deletions content/tooling/cross-compiling.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ On any other system (Windows, 32-bit ARM, RISC-V), use `burn run`, bytecode (`--
(`--target bar`) or JavaScript (`--target js`), which run everywhere bvm or Node.js runs.

```sh
burn version # Burn 26.1.0-experimental-6
burn version # Burn 26.1.0-experimental-7
burnc app.bn # ./app for this computer
file app # Mach-O 64-bit executable arm64, on an Apple silicon Mac
burn dump --asm app.bn # the assembly it was built from
Expand All @@ -33,9 +33,9 @@ burn dump --asm app.bn # the assembly it was built from
- **A C toolchain.** `cc` assembles the generated `.s` file and links the executable. On macOS, install the Xcode
command line tools (`xcode-select --install`); on Linux, `gcc` or `clang` (`apt install build-essential`). Set
`BURN_CC` (or `CC`) to use another one.
- **The runtime.** Every toolchain ships it in `share/burn/lib`: `libburn_runtime.a` (bvm and the runtime core, so
executables can also run embedded bytecode libraries), `libburn_core.a` (the runtime without the standard library,
for [`--no-std`](./no-std.mdx)) and `native-libs.txt` (the system libraries the runtime needs).
- **The runtime.** Every toolchain ships it in `share/burn/lib`: `libburn_runtime.a` (the runtime written in Burn),
`libburn_launcher.a` (bvm written in Burn, for executables that run bytecode) and `native-libs.txt` (the system
libraries the runtime needs).

Nothing else is needed at run time: the executable only uses the C library of the system it runs on.

Expand Down Expand Up @@ -63,19 +63,18 @@ built for it, and `BURN_CC` at a linker for it. For example, from an x86-64 Linu

```sh
sudo apt install gcc-aarch64-linux-gnu libc6-dev-arm64-cross
rustup target add aarch64-unknown-linux-gnu

TARGET=aarch64-unknown-linux-gnu sh scripts/native-runtime.sh ~/burn-runtime-arm64
TARGET=aarch64-unknown-linux-gnu BURN_CC=aarch64-linux-gnu-gcc sh scripts/native-runtime.sh ~/burn-runtime-arm64

BURN_PLATFORM=linux-aarch64 \
BURN_RUNTIME_DIR=~/burn-runtime-arm64 \
BURN_CC=aarch64-linux-gnu-gcc \
burnc app.bn -o app-arm64
```

`scripts/native-runtime.sh` is in the Burn repository; it compiles bvm's runtime with `rustc` for the Rust target
you name (`aarch64-apple-darwin`, `x86_64-apple-darwin`, `aarch64-unknown-linux-gnu` or
`x86_64-unknown-linux-gnu`). `BURN_PLATFORM` alone is enough to look at the generated code:
`scripts/native-runtime.sh` is in the Burn repository; it compiles the runtime written in Burn (and bvm) with `burn`
for the target you name (`aarch64-apple-darwin`, `x86_64-apple-darwin`, `aarch64-unknown-linux-gnu` or
`x86_64-unknown-linux-gnu`) and assembles it with `BURN_CC`. `BURN_PLATFORM` alone is enough to look at the generated code:

```sh
BURN_PLATFORM=macos-aarch64 burn dump --asm app.bn
Expand All @@ -86,7 +85,8 @@ Mac. To try an arm64 Linux executable on an x86-64 computer, run it with `qemu-a

## How it is tested

The test suite (`cargo test`) builds every program in `tests/cases` natively and compares its output with bvm, also
with a small cycle-collection threshold, without the standard library, and with bytecode libraries and mixins. CI
The test suite (`sh scripts/test.sh`, written in Burn in `tests/run.bn`) builds every program in `tests/cases`
natively and compares its output with bvm, also with a small cycle-collection threshold, with the JIT compiling
everything, without the standard library, and with bytecode libraries and mixins. CI
runs it on Linux x86-64 and on a Mac with Apple silicon. On Linux, the suite also cross-compiles every test program to
arm64 and runs it under qemu.
21 changes: 9 additions & 12 deletions content/tooling/installation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ See [the toolchain](./toolchain.mdx) for what each command does.

- Linux or macOS (Windows: see [manual installation](#manual-installation))
- `git`, which burnup and ash use to download Burn versions and packages
- Rust 1.85 or newer for versions built from source (branches such as `master`, and any version without a
prebuilt release), which builds bvm. Pass `--install-rust` to the installer to get it with rustup. Nothing else is
needed: bvm runs the boot compiler that comes with the sources.
- A C compiler (`cc`), `tar` and `xz` for versions built from source (branches such as `master`, and any version
without a prebuilt release): the C compiler assembles the seed that comes with the sources, which builds the rest.
Nothing else is needed, no Burn and no Rust.
- A C toolchain (`cc`) to build native executables with `burnc`. Everything else works without it.

## Versions
Expand Down Expand Up @@ -93,7 +93,6 @@ burnup self uninstall # everything: versions, packages, commands and the
| `--prefix <dir>` | install into `<dir>` instead of `~/.burn` |
| `--toolchain <version>` | the Burn version to install first (default: the latest) |
| `--from-source` | build Burn and burnup from source instead of downloading them |
| `--install-rust` | install Rust with rustup when a source build needs it |
| `--no-ash` | do not install ash |
| `--no-modify-path` | do not touch your shell profile |

Expand Down Expand Up @@ -127,16 +126,14 @@ tar -xzf burn-linux-x86_64.tar.gz

## Manual installation

Any platform with Rust can build the toolchain from a checkout:
Linux and macOS, on x86-64 and arm64, can build the toolchain from a checkout with a C compiler, `tar` and `xz`:

```sh
sh scripts/package.sh --prefix ~/.burn
```

This builds bvm, lets bvm run the boot compiler in `compiler/boot` to compile the compiler written in Burn, lets that
compiler build itself and the command
line, and lays out `bin/` (`burn`, `burni`, `burnc` and `burn-lsp` are bvm, `burnfmt` is a script) and
`share/burn/`. To do it by hand, copy `target/release/bvm` to `bin/bvm` and `bin/burn` (and to `burni`, `burnc`
and `burn-lsp`, or link them), and put the command line module, built with
`bvm compiler/boot/compiler.bvmc build compiler/src/bin/burn.bn -o burn.bvm`, at `share/burn/burn.bvm` next to `bin/`.
`BURN_CLI_BVM` can point at it instead.
This assembles the seed in `compiler/boot` (the compiler written in Burn, as assembly for this platform), lets it
build the compiler from `compiler/src` until the compiler reproduces itself
([how the compiler builds itself](../internals/toolchain.mdx#how-the-compiler-builds-itself)), builds `bin/burn` and
the runtime libraries with it, and lays out `bin/` (`burni`, `burnc`, `burn-lsp` and `bvm` are links to `burn`,
`burnfmt` is a script) and `share/burn/`. It takes under a minute.
Loading
Loading