ROX Language
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.
First Principles
- 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.
Language Guarantees (v0)
- 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
- Automatic namespacing (reserved
roxv26_prefix)
Namespacing (v0)
ROX automatically namespaces all user-defined identifiers to prevent collisions with C++ keywords and standard library symbols.
- User variable
xbecomesroxv26_xin generated C++. - Reserved Components: The following are NOT namespaced:
mainfunction (entry point)- Built-in functions (
print,isOk, etc.) - Standard library constants (
true,false,none)
Rule: You cannot define identifiers starting with roxv26_. Attempting to do so will
result in a compilation error.
Example: Two Sum
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)) {
int64 v2 = getValue(r2);
if (v1 + v2 == target) {
return [i, j];
}
}
}
}
}
return [-1, -1];
}
Notable Properties
.at()returnsrox_result[T]- Errors must be handled explicitly
- No implicit casts
rangeis the only loop construct
Language Features (v0)
Operators
- Arithmetic:
+,-,*,/(returnsrox_result[T]),%(returnsrox_result[T]) - Comparison:
==,<,<=,>,>= - Logical:
and,or,not - Note:
!=and!are not supported. Usenot (a == b)andnot a.
Types
int64float64boolcharnonelist[T]dictionary[K, V]rox_result[T]string(Immutable)- User-defined record types
Control Flow
if/elsefor i in range(start, end, step)for item in collection(iterate lists)breakcontinue
Note: ROX intentionally has no while loop. Every loop must have an explicit upper
bound — either via range(start, upperBound, step) or by iterating a finite collection. This
guarantees all loops terminate.
Built-in Functions
print(val...) -> none(Variadic: accepts one or more arguments)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)
Built-in Constants
pi,e(float64)EOF(string) — error returned byread_line()on end of input
Comments
ROX supports single-line comments starting with //.
// This is a comment
int64 x = 10; // This is also a comment
Math Library
int64
int64_abs(n)int64_min(a, b)int64_max(a, b)int64_pow(base, exp) -> rox_result[int64]
float64
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)
Constants
pi(float64)e(float64)
Error Model
ROX does not use exceptions. Errors are explicit values:
rox_result[int64] r = int64s.at(i);
if (isOk(r)) {
int64 value = getValue(r);
} else {
print("Error: ", getError(r), "\n");
return [-1, -1];
}
Nothing throws. Nothing hides.
User-Defined Types (Records)
Define types with named, typed fields. All fields are required at construction.
type User {
id: int64
name: string
}
function main() -> none {
User u = User{ id: 7, name: "Taman" };
print(u.name, "\n");
User empty = default(User); // zero constructor
print(empty.id, "\n"); // 0
}
Records support field access (u.name), field mutation (u.name = "Apon"),
copy semantics, nested composition, and functions as parameters/return values.
Compile-time checks: missing fields, unknown fields, duplicate fields, type mismatches, and uninitialized declarations are all caught at compile time.
Download & Build
You can verify and run algorithms locally using the Playground or by building the compiler from source.