Documentation/Getting started

Your first BASIL program

On this page

You can begin with one line. No project generator, class hierarchy, or explicit entry point is required.

1. Get the compiler

The current implementation targets Linux x86-64. The supported route here is a source checkout. Bootstrapping needs Git, Python 3, Rust/Cargo, and native build tools (cc, ar, and platform development headers). Optional graphics libraries need additional dependencies described in their guides.

git clone https://github.com/geekhideout/basic.git basil
cd basil
python3 tools/selfhost.py --report docs/selfhost-report.json

This builds the maintained compiler from its frozen seed, checks self-hosting reproducibility, and runs the regression corpus. It does substantial validation, so allow it to finish. A successful build publishes build/selfhost/stage3.

build/selfhost/stage3 --help
build/selfhost/stage3 toolchain

The compiler is written in BASIL. Rust is used for the frozen bootstrap seed; ordinary BASIL application builds use the integrated compiler and native linker. Keep the compiler with its matching native SDK. See the source build documentation for the full development workflow.

2. Say hello

Save this as hello.bas in the repository root:

PRINT "Hello, world!"

Then run it:

build/selfhost/stage3 run hello.bas
Hello, world!

PRINT writes a value and a newline. Quotes mark a string. Top-level statements form the program’s entry point.

3. Build an executable

build/selfhost/stage3 build hello.bas -o build/hello
./build/hello

The result is a native Linux executable. Ordinary standalone programs do not need an interpreter or shared-language runtime. Applications that use native GUI libraries have the system dependencies declared by those libraries.

4. Make it your own

names = ["Ada", "Grace", "Mary"]
FOR EACH name IN names
    PRINT f"Hello, {name}!"
NEXT

The compiler infers a typed list of strings. FOR EACH visits each element, and an f string inserts a value between braces. You get readable syntax and compile-time checking in the same small program.

Where to go next

The source repository still uses basic in several commands and paths. BASIL is the language’s official name; use the command names shown here literally.

Find your way around BASIL

Type to search the manual.