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.
- We no longer write code that must fit on a punch card — readability wins over brevity.
- Code is read far more than it is written. Optimize for the reader, not the writer.
- Code is written in calm and read in crisis.
- Cleverness is often the enemy of clarity.
- No implicit type conversions
- No bracket indexing (
[]only for list literals) - No exceptions — errors are explicit values (
rox_result[T]) - A single loop construct (
for) - 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[int64] int64s, int64 target) -> list[int64] {
int64 n = int64s.size();
for i in range(0, n, 1) {
for j in range(i + 1, n, 1) {
rox_result[int64] r1 = int64s.at(i);
if (isOk(r1)) {
int64 v1 = getValue(r1);
rox_result[int64] r2 = int64s.at(j);
if (isOk(r2)) {g
int64 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()
ROX prioritizes clarity over convenience. Explicitness may cost more keystrokes, but it eliminates hidden behavior.
int64(64 bit signed integer)boolfloat64charstringnonelist[T]dictionary[K, V]rox_result[T]- User-defined record types
if/elsefor i in range(start, end, step)for item in collectionbreakcontinue
print(val) -> none(supports string, int64, float64, bool, char, list)read_line() -> rox_result[string](reads one line from stdin)isOk(rox_result[T]) -> boolgetValue(rox_result[T]) -> TgetError(rox_result[T]) -> stringdefault(T) -> T(zero/empty value for any type)
pi,e(float64)EOF(string) — error returned byread_line()on end of input
int64_abs(n)int64_min(a, b)int64_max(a, b)int64_pow(base, exp) -> rox_result[int64]
float64_abs(n)float64_min(a, b)float64_max(a, b)float64_pow(base, exp)float64_sqrt(n) -> rox_result[float64]float64_sin(n)float64_cos(n)float64_tan(n)float64_log(n) -> rox_result[float64]float64_exp(n)float64_floor(n)float64_ceil(n)
pi(float64)e(float64)
ROX does not use exceptions. Errors are explicit values:
rox_result[int64] r = int64s.at(i);
if (isOk(r)) {
int64 value = getValue(r);
} else {
return [-1, -1];
}
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, int64] scores;
scores.set("Alice", 100);
if (scores.has("Alice")) {
print(scores.get("Alice"));
}
Comments are single-line and start with //.
// This is a comment
int64 x = 10; // This is also a comment
ROX supports user-defined record types with named, typed fields.
type User {
id: int64
name: string
}
function main() -> none {
User u = User{ id: 7, name: "Taman" };
print(u.name, "\n");
u.name = "Apon";
print(u.name, "\n");
// Zero constructor
User empty = default(User);
print(empty.id, "\n"); // 0
}
Records have copy semantics, support nested composition, and enforce all fields at construction time. Functions operate on records as parameters and return values — no methods.
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
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:
./test.shAlternatively, 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.
cd web
npm installnode web/server.jsThen open http://localhost:3000 in your browser.