Skip to content

Hello World

Every Jiang executable starts at main. Its integer return value becomes the process exit status.

Int main() {
    print(42);
    print(false);
    return 42;
}

Compile and run:

jiang hello.jiang -o hello
./hello
echo $?

For byte-oriented output with explicit error handling, use std.io.stdout():

import std;

Int main() {
    std.fs.File output! = std.io.stdout();
    Void written = try output.write_all("Hello, Jiang!\n") catch { return 1; };
    return 0;
}
Int add(Int a, Int b) {
    return a + b;
}

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

Functions use their final expression as the return value when no explicit return is needed.