Examples
The fastest way to learn Rux is to write a little of it. This page walks you through your first program, then points you to a growing collection of worked examples you can clone and run.
Your first program
Let's build a console application that prints Hello, World!.
1. Create the project
Scaffold a new project with the Rux toolchain and open it in your editor:
rux new Hello
cd Hello
code .
2. Write the code
Replace the contents of Src/Main.rux with:
import Io::Print;
func Main() -> int {
Print("Hello, World!");
return 0;
}
Main is the program's entry point, and the import brings Print from the standard library's Std::Io module into scope.
3. Add the standard library
rux add Std
rux install
4. Build and run
rux build
rux run
You should see:
Hello, World!
More examples
Once your first program runs, explore the Rux Examples repository — a collection of small, self-contained projects that introduce core concepts one step at a time.
Repository layout
Each example is its own complete project:
Examples/
├── Hello/
│ ├── Src/
│ │ └── Main.rux
│ └── Rux.toml
├── Factorial/
│ ├── Src/
│ │ └── Main.rux
│ └── Rux.toml
├── ...
└── README.md
Run an example
- Clone the repository:
git clone https://github.com/rux-lang/Examples.git cd Examples - Move into an example and open it:
cd Hello code . - Read its README for the task and learning goals, then build and run it:
rux run
Tips
- Read the problem carefully before you start coding.
- Experiment — modify an example and see what changes.
- Write clear comments as you go.
- Found a bug or have an idea? Open an issue on GitHub.
All examples are released under the MIT License.
Zed
Zed is a fast, multiplayer code editor for macOS and Linux. The official Rux extension adds syntax highlighting for .rux source files.
Table of Contents
The complete Rux language reference — covering lexical structure, primitive types, variables, functions, structs, enums, interfaces, modules, error handling, FFI, and compile-time programming.