Skip to content

Hello, World!

Let’s begin by writing and executing a minimal program in Wysna.

Create a file named main.wysna:

## main.wysna
fn greet(name: str) -> str {
return "Hello, " + name + "! Welcome to Wysna."
}
fn main() -> unit {
let message = greet("World")
print(message)
}

Let’s break down each element of this program:

  1. Comments: Comments begin with double hashes ## (or single # for inline comments).
  2. Function Declaration (fn):
    • greet accepts a parameter name of type str and returns a str.
    • In Wysna, function parameter types and return types are explicit.
  3. String Concatenation: Strings are managed buffers that support concatenation using the + operator with automatic ARC lifecycle tracking.
  4. The main Entry Point:
    • Every executable program defines an entry point named main().
    • Its return type is unit (indicating no meaningful return value, analogous to void in C or () in Rust).
  5. Immutable Variables (let):
    • let message = greet("World") binds message. By default, variables defined with let are immutable.
  6. Built-in print:
    • print(...) writes formatted strings and values to standard output (stdout) followed by a newline.

You can compile and immediately execute the program with a single command:

Terminal window
wysna run main.wysna

Output:

Hello, World! Welcome to Wysna.

To produce a native binary file for distribution:

Terminal window
wysna build main.wysna -o app
./app