Running Reox Code

Learn how to compile and run .rx and .reox files.

File Extensions

Reox supports two file extensions that are completely equivalent:

.rx

Short form - convenient for quick scripts

.reox

Full form - recommended for projects

Run Directly (Interpreter Mode)

For quick testing, run code directly with the interpreter:

# Run a .rx file
$ reoxc --run hello.rx

# Run a .reox file
$ reoxc --run app.reox

# Short form
$ reoxc -r script.rx

Compile to C

Generate optimized C code for production:

# Compile to C code
$ reoxc main.rx -o main.c

# Then compile with GCC/Clang
$ gcc main.c -o myapp -lm
$ ./myapp

Compile to Executable

Create a standalone executable with optimization:

# Full optimization pipeline
$ reoxc app.reox --emit exe -o myapp -O3 --lto

# Options:
#   --emit exe   Generate executable
#   -O3          Maximum optimization
#   --lto        Link-time optimization
#   --strip      Remove debug symbols

Imports and Modules

Split your code into multiple files using import:

// math_utils.rx
fn square(x: int) -> int {
    return x * x;
}

fn cube(x: int) -> int {
    return x * x * x;
}
// main.rx
import math_utils;

fn main() {
    let result = square(5);
    print(result);  // 25
}

Entry Point

For executable programs, define a main function:

// A complete Reox program

fn greet(name: string) {
    print("Hello, " + name + "!");
}

fn main() {
    greet("NeolyxOS");
}

Best Practices

  • Use .reox for main application files
  • Use .rx for utility modules and scripts
  • Keep one main() function per executable
  • Use -O3 --lto for production builds
  • Test with --run before compiling