01 / Prepare

Build the tools

Clone Ziran and build the tools. You need a C compiler and make. Go is needed only when compiling generated Go output.

git clone https://github.com/kryonlabs/ziran.git
cd ziran
make

To run the project’s tests, use make check. Prebuilt downloads are not available yet.

02 / Source

Write a module

Save this as hello.zi. A source file is a module named after its filename.

Score :: struct {
    value: s32;
    bonus: s32;
}

Total :: (score: Score) -> s32 {
    return score.value + score.bonus;
}

Answer :: () -> s32 {
    score: Score = Score.{value = 40, bonus = 2};
    return Total(score);
}

Download hello.zi ↓

03 / Check and execute

Run the checked program

build/bin/ziran check --root . hello.zi
build/bin/ziran bundle --root . --entry hello:Answer -o hello.zib hello.zi
build/bin/ziran run hello.zib

The last command prints 42. To save checked IR, use build/bin/ziran ir --root . -o out hello.zi. Native output uses build/bin/ziran build --target=c, --target=cpp, or --target=go with the usual root and output options.

Keep going

Follow the source contract