ROX is a minimal, clarity-first programming language built on a simple belief:
Programming logic should not have to fight the language.
ROX removes implicit behavior, hidden conversions, and syntactic tricks so that expressing logic feels direct and mechanical rather than negotiated.
ROX compiles .rox source files into C++20 (.cc), which are then compiled into native executables using clang++.
This repository contains the ROX compiler implementation written in C++20.
In many languages, expressing simple logic often requires navigating:
- Implicit type coercions
- Silent conversions
- Operator overloading
- Hidden control flow
- Exception systems
- Special cases
ROX intentionally removes these.
The goal is not convenience. The goal is clarity of expression.
In ROX:
- Every type is explicit.
- Every error is a value.
- Every access is deliberate.
- Every control structure is visible.
- Nothing implicit happens behind your back.
You write the logic. The language stays out of the way.
ROX v0 enforces:
- No implicit type conversions
- No bracket indexing (
[]only for list literals) - No exceptions — errors are explicit values (
rox_result[T]) - A single loop construct (
repeat) - Explicit control flow only
- Strict compile-time type checking
The surface area is intentionally small and opinionated.
Two Sum implemented in ROX:
function two_sum(list[num] nums, num target) -> list[num] {
num n = nums.size();
repeat i in range(0, n, 1) {
repeat j in range(i + 1, n, 1) {
rox_result[num] r1 = nums.at(i);
if (not isOk(r1)) { return [-1, -1]; }
num v1 = getValue(r1);
rox_result[num] r2 = nums.at(j);
if (not isOk(r2)) { return [-1, -1]; }
num v2 = getValue(r2);
if (v1 + v2 == target) {
return [i, j];
}
}
}
return [-1, -1];
}
.at()returnsrox_result[T]- Errors must be handled explicitly
- No implicit casts
rangeis the only loop construct- Lists are accessed only via
.at()
The language forces clarity — not ceremony.
num(64 bit signed integer)num32(32 bit signed integer)boolcharstringnonelist[T]dictionary[K, V]rox_result[T]
if/elserepeat i in range(start, end, step)breakcontinue
print(val) -> none(supports string, num, float, bool, char, list)isOk(rox_result[T]) -> boolgetValue(rox_result[T]) -> TgetError(rox_result[T]) -> string
num32_abs(n)num32_min(a, b)num32_max(a, b)num32_pow(base, exp) -> rox_result[num32]
num_abs(n)num_min(a, b)num_max(a, b)num_pow(base, exp) -> rox_result[num]
float_abs(n)float_min(a, b)float_max(a, b)float_pow(base, exp)float_sqrt(n) -> rox_result[float]float_sin(n)float_cos(n)float_tan(n)float_log(n) -> rox_result[float]float_exp(n)float_floor(n)float_ceil(n)
ROX does not use exceptions. Errors are explicit values:
rox_result[num] r = nums.at(i);
if (not isOk(r)) {
return [-1, -1];
}
num value = getValue(r);
To get the error message:
if (not isOk(r)) {
print("Error: ", getError(r), "\n");
}
Nothing throws. Nothing hides.
Strings are immutable sequences of UTF-8 bytes.
string s = "Hello, World!";
print(s);
print("\n");
Hash maps for key-value storage.
dictionary[string, num] scores;
scores.set("Alice", 100);
if (scores.has("Alice")) {
print(scores.get("Alice"));
}
Comments are single-line and start with //.
// This is a comment
num x = 10; // This is also a comment
ROX is compiled, not interpreted.
.rox → .cc → native binary
- ROX source is parsed and type-checked.
- C++20 code is generated.
clang++compiles the emitted C++ into an executable.
The generated C++ is intentionally straightforward and readable.
- C++20-compatible compiler (e.g.,
clang++) - Make
./rox run test/two_sum.rox./rox format test/two_sum.rox./rox generate test/two_sum.rox./rox compile test/two_sum.roxYou can run all verified test programs with the provided script:
Alternatively, run them individually:
./rox run test/two_sum.roxThe test/ directory contains verified implementations of:
- Two Sum
- Valid Parentheses
- Binary Search
- Maximum Subarray (Kadane’s Algorithm)
- Longest Substring Without Repeating Characters
These serve as correctness and regression tests for the compiler pipeline.
ROX v0 focuses on:
- Core type system
- Explicit error handling
- Deterministic control flow
- Clean C++ code generation
- Minimal language surface
Future directions (ROX++) may include:
- Module system
- Expanded standard library
- Static analysis improvements
ROX is not trying to compete with mainstream languages. It is an exploration of this question:
What does programming look like when the language refuses to be clever?
A local web-based playground is available to try ROX code interactively.
Then open http://localhost:3000 in your browser.