Burn is a statically typed programming language with type inference and smart casts. You run programs directly while you work on them, and build them into native executables, bytecode or JavaScript when you ship them. Burn is written in Burn.
Current version: 26.1.0-experimental-9. Burn is not ready for production yet, and its syntax may still change.
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"
}
fun main() {
print(describe(new Circle(2)), describe("text"))
}
curl -fsSL https://raw.githubusercontent.com/burnlang/burnup/master/install.sh | shThis installs burnup, the toolchain and ash,
the package manager, into ~/.burn/bin. Burn runs on Linux and macOS, on x86-64 and arm64. Building native
executables needs a C compiler (cc).
burni app.bn # run a program
burni # start the REPL
burnc app.bn # build a native executable ./app
burnc app.bn --target js # or JavaScript, bytecode (bvm) or a runnable archive (bar)
burnfmt -w app.bn # format a file
ash init # start a project
ash install github.com/you/lib # add a packageEditors get completion, errors, hover and go to definition from burn lsp; there are extensions for
VS Code, IntelliJ and
Zed.
- Types are inferred, and checks such as
x is stringorx != nullnarrow a variable's type (smart casts).T?marks a value that can benull. def type,def struct,def interface,def enumanddef annotationdefine every kind of type. Structs have constructors, methods, inheritance and static members.- Generics,
match, closures,async/awaiton threads, sized numbers (uint8,float32, …) and checked integer overflow. - Memory is freed by reference counting that the compiler inserts, with a collector for cycles; there is no garbage collector pause and nothing to free by hand.
unsafecode can use raw memory, inline assembly and C functions (@Extern).- The standard library covers strings, collections, math, files, processes, dates and times, JSON and HTTP.
burni compiles a program to bytecode for bvm, the Burn virtual machine, and runs it right away. bvm interprets code
at first and compiles functions that run often to x86-64 or arm64 machine code, so hot code runs close to native
speed. burnc compiles a program to native code instead, or to JavaScript.
The compiler, the toolchain, bvm and the runtime are all written in Burn. To build Burn from source you only need a C
compiler: the repository keeps the compiler as assembly (compiler/boot), which builds the current sources.
The documentation is at s42yt.github.io/burn-docs: the language, the standard library, the tools, bvm, how Burn works inside, and the changelog. Its sources are in burnlang/docs.
| Folder | Holds |
|---|---|
compiler/ |
the compiler, the command line, bvm, the language server and burn doc (compiler/README.md) |
lib/std/ |
the standard library |
lib/rt/ |
the runtime of compiled programs and bvm |
lib/tools/ |
the formatter and other tools written in Burn |
tests/ |
test programs and the end-to-end tests |
examples/ |
example programs, and Ember, a small language built on bvm |
scripts/ |
building, testing and bootstrapping the toolchain |
sh scripts/package.sh --prefix ~/.burn # build and install the toolchain from this checkout
sh scripts/test.sh # build a toolchain and run every testContributions are welcome: open an issue or a pull request, and add a test in tests/cases/ for new language
features.
GPL-3.0, see LICENSE.