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?
- The
sfnCLI invoked the Sailfin compiler - The compiler parsed
hello.sfn, checked types and effects, emitted.sfn-asmIR, and lowered it to LLVM IR - LLVM compiled the IR to a native binary
- The binary executed and printed the message
Next Steps
- Tour of Sailfin — A deeper walkthrough of language features
- Language Basics — Variables, types, and control flow