Nyx by Example

Hello World

Every programming journey starts here. This is the smallest complete Nyx program: it defines a main function, calls print twice, and returns 0 to signal success. No imports, no boilerplate — just the code that matters.

Code

// Programa mínimo: imprime un saludo al mundo

fn main() -> int {
    print("Hello, world!")
    print("Bienvenido a Nyx")
    return 0
}

Output

Hello, world!
Bienvenido a Nyx

Explanation

Every Nyx program starts execution from the main function. The return type -> int tells the compiler that main returns an integer — by convention, 0 means success and any other value signals an error to the operating system.

The built-in print function writes a string to standard output followed by a newline. It accepts a single String argument. Unlike many languages, Nyx does not require you to import anything to use print — it is always available.

Comments start with // and extend to the end of the line. They are ignored by the compiler and exist only for human readers.

Next →

Source: examples/by-example/01-hello-world.nx