Hello, World!

Your First Program

Create a file called hello.sfn:

fn main() ![io] {
    print.info("Hello, World!");
}

Notice the ![io] effect annotation — this tells the compiler that main performs IO operations. Sailfin requires you to declare capabilities explicitly. If you removed ![io], the compiler would reject the print.info call.

Run It

sfn run hello.sfn

Output:

Hello, World!

What Just Happened?

  1. The sfn CLI invoked the Sailfin compiler
  2. The compiler parsed hello.sfn, checked types and effects, emitted .sfn-asm IR, and lowered it to LLVM IR
  3. LLVM compiled the IR to a native binary
  4. The binary executed and printed the message

Next Steps