Skip to main content

Overview

The Hello World example is the simplest possible Dryft program. It demonstrates the basic structure of a Dryft program and how to output text to the console.

Source Code

include: std/io

act: main
	"Hello, World!\n" prints ;

What This Example Demonstrates

This example shows:
  • Module inclusion: Using include: std/io to import standard I/O functionality
  • Action definition: Defining the main action, which is the entry point of the program
  • String output: Using the prints function to output a string to the console
  • Basic syntax: The stack-based nature of Dryft where data comes before operations

How It Works

  1. The program includes the standard I/O module which provides the prints function
  2. The main action is defined as the program’s entry point
  3. The string "Hello, World!\n" is pushed onto the stack
  4. The prints function pops the string from the stack and outputs it to the console
  5. The semicolon ; terminates the action body
In Dryft, operations are stack-based, meaning data is pushed onto a stack and operations consume values from the stack.

Compiling and Running

To compile and run this example:
1

Compile the program

dryft compile examples/hello.dry -o hello
2

Run the executable

./hello

Expected Output

Hello, World!
This is a great starting point for learning Dryft’s syntax and understanding how stack-based programming works.

Build docs developers (and LLMs) love