Skip to content

Your first program

Int main() {
println("Hello, Resid!");
return 0;
}
Output
Hello, Resid!

Save it as hello.resid and build:

Terminal window
residc hello.resid -o hello --profile debug
./hello

main returns the process exit status. println writes a line to standard output; printing needs no capability.

Profile What you get
release (default) -O2, signed; needs a signing key
debug -O0, DWARF debug info, the knowledge graph artifact, unsigned without a key
check type checking only, plus the graph artifact; no binary

Next to the binary the compiler writes sidecars: hello.resid-graph.cbor (the knowledge graph: every node, what was reduced and why; see Knowledge graph) and hello.resid-notes.cbor (residual notes: the runtime work you could still remove). hello.ll is the LLVM IR.

@requires(args)
Int main() {
Int n = args.count();
println(f"called with {n - 1} argument(s)");
return 0;
}

Reading the command line is an effect that needs authority, so main declares @requires(args). Leave the annotation out and the compiler rejects the program with E0219. The capabilities chapter explains why.

f"...{expr}..." is an f-string; any value can go inside the braces.