01 / Prepare
Build the tools
Clone Ziran and run the local test suite. A C compiler and make are needed for the toolchain; native Go output also needs Go.
git clone https://github.com/kryonlabs/ziran.git
cd ziran
make
make checkmake check runs language, native backend, host capability, and portable bundle tests for the supported subset.
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);
}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.zibThe last command reports 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