Skip to content

Getting Started

This guide assumes you have built jiangc from the main repository. If not, start with Installation.

Create hello.jiang:

Int add(Int a, Int b) {
return a + b;
}
Int main() {
return add(40, 2);
}

A Jiang function always has a return type. The process entry point is main; returning 42 gives the host process exit code 42.

From the Jiang repository:

Terminal window
./build/jiangc hello.jiang -o hello

Run it:

Terminal window
./hello
echo $?

The result should be 42.

During language development it is often useful to inspect the generated LLVM IR:

Terminal window
./build/jiangc --emit-llvm hello.jiang

Use -o to write the IR to a file:

Terminal window
./build/jiangc --emit-llvm hello.jiang -o hello.ll

Jiang source is declaration-oriented. A small file usually contains type declarations, functions, and a main function:

struct Pair {
Int left;
Int right;
}
Int sum_pair(Pair pair) {
return pair.left + pair.right;
}
Int main() {
Pair pair = Pair { left: 20, right: 22 };
return sum_pair(pair);
}

Next, read the syntax overview and types guide.