NERD achieves significant token savings (50-70%) by replacing verbose syntax and symbols with dense, single-token English words. This makes generation cheaper and allows more code to fit within LLM context windows.
Basic Math Example
TypeScript:
function add(a, b) { return a + b; }
function sub(a, b) { return a - b; }
function mul(a, b) { return a * b; }
function div(a, b) { return a / b; }
NERD:
fn add a b
ret a plus b
fn sub a b
ret a minus b
fn mul a b
ret a times b
fn div a b
ret a over b
Result: ~67% fewer tokens.
Complex Logic Example (Calculator)
TypeScript:
type Input = { a: number; b: number; op: number };
type Result = { ok: number } | { err: string };
function calc(input: Input): Result {
if (input.op === 0) return { ok: input.a + input.b };
if (input.op === 1) return { ok: input.a - input.b };
if (input.op === 2) return { ok: input.a * input.b };
if (input.op === 3) return { ok: input.a / input.b };
return { err: "unknown" };
}
NERD:
type input num num int
type result ok num or err str
fn calc input result
if third eq zero ret ok first plus second
if third eq one ret ok first minus second
if third eq two ret ok first times second
if third eq three ret ok first over second
ret err unknown
Result: ~59% fewer tokens.