burn / docs

Tools

Building without the standard library

A program can be built with only the core of the language: no standard library modules and none of the features behind them (threads for async fun, the HTTP client, JSON, processes, time zones and bytecode libraries). The checker rejects everything else, so such a program depends on nothing but the core of the language.

burn build app.bn --no-std

or, for a project, in burn.toml:

[package]
name = "github.com/you/tool"
std = false

The language does not change. Strings, arrays, maps, structs, interfaces, generics, closures, match, smart casts, templates and automatic memory all work the same way, and so do runtime errors, overflow checks and stack overflow detection. The executable only needs the C library and libm.

What is available

Only the built-in core, which needs no import:

  • printing and reading: print, eprint, write, input, readStdin
  • conversions: toString, toInt, toFloat, isInt, isNumber, typeOf and as casts
  • strings, arrays and maps with all their operations, like len, split, join, push, sort, keys and has
  • wrappingAdd, wrappingSub and wrappingMul on integers

What is not

Feature Why
any import "std/...", for example std/math or std/strings the standard library is turned off
the functions that live in standard modules, like sqrt, readFile, exit, now or assert they belong to std/math, std/fs, std/process, std/time and std/testing
async fun and await they run on threads
bytecode libraries (import "lib.bvmc") they run on bvm

Using one of these is a compile error that points at the import or the call:

error: `std/math` is part of the standard library
 --> src/main.bn:1:8
  |
1 | import "std/math"
  |        ^^^^^^^^^^
  = help: this program is built without the standard library (`std = false` in burn.toml, or `--no-std`); only the built-in core is available, so remove that setting to use it

The same checks run with burn check, burn run and in the editor, so a project with std = false reports these errors before it is built, and the editor does not suggest standard library imports. burn run still runs the program on bvm, which makes no difference to what it prints.

How it works

The checker keeps the standard library out of the program and rejects the built-in features that need it, but a native executable links the same runtime written in Burn either way, and the linker drops the runtime code the program does not use (--gc-sections). Until 26.1.0-experimental-7 the runtime was written in Rust and --no-std linked a smaller build of it without Rust's standard library; now every program gets the small runtime, so hello world is about 220 KB with or without --no-std.