Skip to content
Draft

Hello World

Let’s create your first Draft program and run it.

Create a file named main.draft:

action main()
write("Hello, world!")
fin action.

Let’s break down what this program does:

Element Meaning
action Declares the start of a function definition
main() The function name with its parameter list
write(...) Prints output to the console
fin action. Ends the action definition

Navigate to the directory containing main.draft and run:

Terminal window
draft run main.draft

You should see:

Hello, world!

To produce a standalone executable:

Terminal window
draft build main.draft -o hello

Then run the compiled binary:

Terminal window
./hello # macOS / Linux
hello.exe # Windows

Here’s a program that takes user input:

action main()
write("What is your name?")
@name = read_line()
write("Hello, " + @name + "!")
fin action.

Run it:

Terminal window
draft run main.draft

Output:

What is your name?
> Earl
Hello, Earl!
  • Actions — Functions in Draft are called actions. They start with action and end with fin action.
  • Variables — Prefixed with @ (e.g., @name). They are immutable by default.
  • Standard Librarywrite() and read_line() are from the io module, automatically imported.

Learn about Project Structure to organize your Draft projects properly.