Install Zero

You can try every part of Zero in this site's playground and tutorial: the compiler runs in your browser. To compile programs on your own machine, build the compiler from source.

Build the compiler

Zero is written in C++20 and has no dependencies besides CMake 3.20 or newer and a C++20 compiler: Clang, MSVC, or GCC. On Windows, the Visual Studio developer tools provide everything; Ninja is recommended everywhere.

  1. Configure and build

    From a checkout of the Zero repository:

    cmake -S . -B build/native -DCMAKE_BUILD_TYPE=Release
    cmake --build build/native --config Release --target zero

    The compiler is build/native/bin/zero (or build/native/bin/Release/zero with a multi-configuration generator).

  2. Run a program

    Save this as hello.zero:

    fun main()
        let answer = 6 * 7
        assert answer == 42
    end
    zero hello.zero

    The program runs in the interpreter. It exits with status 0 when every assertion holds, and prints a diagnostic otherwise.

  3. Run the tests (optional)

    ctest --test-dir build/native -C Release --output-on-failure

Choose how a program runs

CommandWhat it does
zero app.zeroChecks the program and runs it in the interpreter.
zero --stop-after check app.zeroOnly checks it: syntax, types, and every other compile-time rule.
zero --jit app.zeroCompiles to native x64 or ARM64 code and runs it in the same process.
zero --compile-native app.exe app.zeroWrites a standalone native executable.
zero --compile-cpp app app.zeroGenerates C++20 and compiles it with your C++ compiler.
zero --emit-cpp app.cpp app.zeroWrites the generated C++20 source.

Run zero --help for every option, and read The Toolchain for details.

Editor support

The compiler is also a language server (zero --lsp) and a debug adapter (zero --dap). The repository's vscode/ folder contains a Visual Studio Code extension that uses both: package it with npx vsce package and install the resulting .vsix with code --install-extension.

The compiler in the browser

This site runs the same compiler and interpreter, built for WebAssembly with Emscripten. It checks and runs programs, and answers the editor's questions (completion, hover, go to definition). It cannot generate native code or load native libraries; programs that print use the browser's zero.console library instead.