The Drib Programming Language

Language version adi 0.8.0 (Dec 14, 2025)

Introduction

Drib is an esoteric programming language that represents every number as a string. Arithmetic and logic are performed via built-in functions operating on those string values, offering a quirky, mind-bending take on computation. This project includes a lightweight interpreter with a REPL, file execution, and optional Python code generation.

Variables

A variable is a named storage location that holds a value you can read and update while your program runs.

In Drib, variables can store strings, booleans (true/false), or nil. Numbers are represented as strings, and math is done via built-ins (e.g., add, sub).

val message = "Hello";
println(message); // prints: Hello
message = "Hello, Drib!";
println(message); // prints: Hello, Drib!

when... then

Use when(condition) to run code only when the condition evaluates to true, and add an optional otherwise block for the false case. Conditions are boolean expressions, typically built with built-ins like eqs, gt, and lt. Parentheses are required after when, and blocks use braces.

val x = "12";
when(gt(x, "10")) {
  println("bigger");
} otherwise {
  println("smaller or equal");
}

Built-in functions

Built-in functions are core utilities provided by a language/runtime, available without importing anything (e.g., print, len, abs).

add

Sum two numeric strings; returns number string.

val r = add("2", "3");
println(r); // "5"

sub

Difference of two numeric strings.

val r = sub("10", "4");
println(r); // "6"

mul

Product of two numeric strings.

val r = mul("6", "7");
println(r); // "42"

div

Division; int division if both ints, handles 0/Infinity/NaN.

println(div("7", "2")); // "3" if ints, "3.5" if any float
println(div("7", "0")); // "Infinity"

pow

Exponentiation a^b on numeric strings.

println(pow("2", "8")); // "256"

mod

Remainder a % b for numeric strings.

println(mod("17", "5")); // "2"

gt

Numeric greater-than; returns boolean.

println(gt("3", "2")); // True

lt

Numeric less-than; returns boolean.

println(lt("2", "3")); // True

geq

Numeric greater-or-equal; returns boolean.

println(geq("3", "3")); // True

leq

Numeric less-or-equal; returns boolean.

println(leq("2", "3")); // True

eqs

Equality; numeric if possible else string compare.

println(eqs("2", "2")); // True

et

Logical AND of two booleans.

println(et(gt("3", "2"), lt("1", "5"))); // True

aut

Logical OR of two booleans.

println(aut(lt("3", "2"), gt("1", "0"))); // True

not

Logical NOT of a boolean.

println(not(eqs("1", "2"))); // True

print

Print without trailing newline.

print("Hello");
println(" world!"); // same line output

println

Print with trailing newline.

println("Hello, Drib!");

list

Create a list from arguments.

val a = list("1", "2", "3");
println(a);

get

Get element at index from list.

val a = list("10", "20", "30");
println(get(a, "1")); // "20"

set

Set element at index in list.

val a = list("10", "20", "30");
set(a, "1", "42");
println(a); // "10","42","30"

size

Length of list; returns number string.

val a = list("a", "b", "c");
println(size(a)); // "3"

imread

Load image as 2D array of RGB string triples.

val img = imread("./examples/assets/lenna.png");
println(size(img), "x", size(get(img, "0"))); // height x width

imwrite

Save 2D array of RGB ints to an image file.

val img = zeros("2", "2"); // 2x2 black
imwrite(img, "./out.png");
println("saved ./out.png");

zeros

Create WxH black image (RGB "0" strings).

val z = zeros("3", "2"); // width=3, height=2
println(size(z), "x", size(get(z, "0"))); // "2 x 3"

int

Convert numeric to int string; handles Infinity/NaN.

println(int("3.7")); // "3"
println(int("Infinity")); // "Infinity"

sqrt

Square root; returns number string or "NaN".

println(sqrt("9")); // "3.0"
println(sqrt("-1")); // "NaN"

abs

Absolute value; returns number string; handles Infinity/NaN.

println(abs("-42")); // "42"
println(abs("Infinity")); // "Infinity"