TypeScript syntax.
Native speed.

A statically‑typed, compiled language with TypeScript syntax. Write familiar source; it type‑checks and compiles straight to a small, fast native binary.

curl -fsSL https://raw.githubusercontent.com/labidiaymen/ljs/main/install.sh | sh
.ts source type check optimize native binary

Hello, Lumen

Familiar syntax, fixed static types, no runtime — just a native executable.

interface Point {
  x: int;
  y: int;
}

function distanceSq(a: Point, b: Point): int {
  let dx = a.x - b.x;
  let dy = a.y - b.y;
  return dx * dx + dy * dy;
}

let origin: Point = { x: 0, y: 0 };
let p: Point = { x: 3, y: 4 };
console.log(`distance² = ${distanceSq(origin, p)}`);  // distance² = 25

What's in the language

A predictable static subset of TypeScript — no prototypes, no eval, no dynamic shapes.

Static types

Local inference, int/i64/number/bool/string, float & hex/binary literals.

Records & interfaces

Closed object shapes, nested records, arrays of records, enums.

Full control flow

if/else if, while, do, C‑style for, for…of, switch, ternary.

Null safety

T | null, optional ? fields, ??, ?., and if (x != null) narrowing.

First-class functions

Function types, arrow functions, and capturing closures.

Classes

Fields, constructor, this, and methods — instances lower to heap structs.

Template literals

`hi ${name}` with string & numeric interpolation.

defer

Scope‑exit cleanup, last‑in‑first‑out.

Built-in tests

test "…" { expect(…); } run with lumen test.

C FFI

extern function + // @link call native C libraries — and C++ via an extern "C" shim.

Native output

Compiles to a small, fast, dependency‑free native binary.

Closures that compile

Capture locals by value — lowered to a heap environment, no GC.

function makeAdder(n: int): (x: int) => int {
  return (x: int) => x + n;
}

let add10 = makeAdder(10);
console.log(add10(5));   // 15

let factor = 3;
let nums: int[] = [1, 2, 3];
for (const v of nums) {
  console.log((v: int) => v * factor);  // closes over `factor`
}

Classes

Fields, a constructor, this, and methods — instances are heap structs.

class Counter {
  count: int;
  constructor(start: int) {
    this.count = start;
  }
  increment(): void {
    this.count += 1;
  }
  get(): int {
    return this.count;
  }
}

let c = new Counter(5);
c.increment();
console.log(c.get());   // 6

Call native libraries

Declare an extern function and link a C library — no bindings generator, no runtime.

// @link m
extern function pow(base: number, exp: number): number;
extern function sqrt(x: number): number;

let hypotSq = pow(3.0, 2.0) + pow(4.0, 2.0);
console.log(sqrt(hypotSq));   // 5
console.log(pow(2.0, 10.0));  // 1024

C++ through an extern "C" shim

Lumen links the C ABI, so expose the C++ you need behind extern "C", then link the object.

// geometry.cpp
extern "C" int rectangle_area(int w, int h) { return w * h; }
// demo.ts
// @link ./geometry.o
extern function rectangle_area(w: int, h: int): int;
console.log(rectangle_area(6, 7));   // 42

V1 FFI passes scalar arguments (int, i64, number, bool). This links local/system libraries — it is not a package manager.

Quickstart

Install the self-contained lumen compiler — nothing else required.

Install (macOS / Linux)

curl -fsSL https://raw.githubusercontent.com/labidiaymen/ljs/main/install.sh | sh

Windows: download the .zip from the releases page.

Compile and run a program

lumen compile hello.ts
./hello

Run tests

lumen test math.test.ts

The native code Lumen generates is an implementation detail — you think in the TypeScript-syntax source language.