Skip to content

Hello World

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

Int main() {
    print("Hello, Jiang!");
    return 0;
}

Compile and run:

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

The program prints Hello, Jiang! followed by a newline and exits with status 0. print is available without an import. See Output for supported types.

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.