Skip to content

Hello World

Create a file called hello.zap:

fn main() {
print("Hello, World!")
}

Run it:

Terminal window
zap run hello.zap

Output:

Hello, World!

Let’s break down every part of that tiny program:

Every Zap program starts execution in the main function. It takes no arguments and returns nothing (implicitly returns void).

print is a built-in function available everywhere without an import. It writes its argument to standard output followed by a newline.

This is a string literal — a sequence of characters enclosed in double quotes. Zap strings are UTF-8 encoded and immutable by default.

Let’s make it slightly more interesting:

fn main() {
let name = "Zap"
let version = 1
print("Welcome to " + name + " v" + str(version) + "!")
}
Welcome to Zap v1!
  • let declares an immutable binding.
  • + concatenates strings.
  • str() converts a value to its string representation.

Now that you’ve seen Zap in action, explore the Language Reference to learn about types, functions, and control flow.