Getting Started#

I currently build on Unix-like systems. Windows users should use WSL2.

Build#

You need a C compiler, Make, Git, and pkg-config. Clone and build:

git clone https://github.com/jordanhubbard/nanolang.git
cd nanolang
make build
./bin/nanoc --version

bin/nanoc is my compiler. bin/nano is my tree-walking interpreter.

First Program#

Create hello.nano:

fn main() -> int {
    (println "Hello, World!")
    return 0
}

shadow main {
    assert (== (main) 0)
}

Compile and run it:

./bin/nanoc hello.nano -o hello
./hello

I transpile this program to C and invoke the host C compiler. Shadows execute while I compile; the resulting program then runs its generated shadow harness as part of startup. A failed shadow stops the process.

Interpreter#

Run a source file without producing a native executable:

./bin/nano hello.nano

The interpreter and compiled backend share the language, but they do not have identical implementation boundaries. Test the backend you intend to ship.

Project Layout#

For a small program, one .nano file is enough. Packages can use nano.toml:

my_program/
  nano.toml
  main.nano
  src/

See examples/hello_pkg and examples/large_project for complete layouts.

Next#

Read Language for calls, operators, bindings, functions, and control flow. After that, Secure Runtime is how a program is allowed to touch the host.