Getting Started with NG
NG compiles and runs through a single tool, ngi, which drives the full pipeline (parse → resolve → typecheck → FlowIR → QBE IL → native executable) for a file or an inline source unit.
Requirements
- macOS or Linux with a modern C++ compiler (the build pins
clang/clang++with libc++ on macOS; Homebrew LLVM providesclang-tidy/clang-format). - CMake ≥ 3.25 and Ninja.
Build
cmake -S . -B build -GNinja
cmake --build build -jThis produces:
build/ngi— the NG frontend (headless).build/ng_test— the full Catch2 test suite (runctest --test-dir build).
Run your first program
Write hello.ng:
import prelude;
fun main() -> i64 {
print("hello, NG");
return 42;
}Run it:
./build/ngi hello.ngOutput:
compiled 32 vNext function(s)
hello, NG
native main exited with code 42main may return nothing (unit), i64, f64, or string; string and float returns are printed to stdout, and an integer return becomes the process exit code reported by the driver.
Inline source
ngi --source compiles and runs a source unit directly, and ngi --expr parses a single expression:
./build/ngi --source 'import prelude; fun main() { print(1 + 2); }'
./build/ngi --expr '2 * 3 + 4'Native compilation
NG can compile programs to native executables using the --native flag. The --output flag specifies the output file path:
./build/ngi --native --output hello hello.ng # compile to native executable
./build/ngi --native hello.ng # compile and run immediatelyNative executables are self-contained and don't require the NG runtime at execution time. See Language Guide: Why NG? for binary size comparisons with other languages.
Interactive programs
GUI/interactive programs run a frame loop (see ImGui Integration):
./build/ngi example/ng_ide.ngTests and examples
./build/ng_testruns the whole suite (1700+ assertions across 430+ cases), including a sweep that runs everyexample/*.ngend to end.example/holds one runnable example per feature area — a great way to learn by reading.