lux-lang

Crates.iolux-lang
lib.rslux-lang
version0.0.1-alpha.1
created_at2025-04-18 01:51:49.238586+00
updated_at2025-04-18 01:51:49.238586+00
descriptionThe Lux programming language
homepage
repositoryhttps://github.com/kimkim480/lux
max_upload_size
id1638706
size271,114
Eric Camara (kimkim480)

documentation

README

Lux Banner


What is Lux?

  • Lux is a statically typed, stack-based programming language designed for learning and exploration.
  • It is built from scratch in Rust with a custom virtual machine called Prism.
  • Its purpose: to shine light through the chaos of runtime errors โ€” with clarity, intention, and precision.

Goals of Lux

  • Clarity over cleverness
  • Static typing from the ground up
  • Minimalist syntax, inspired by light and structure
  • Built to learn, not necessarily to ship

โœจ Features

  • ๐Ÿง  Statically typed with Light, Lumens, Photon, Umbra
  • ๐Ÿ” Control flow: for, if/else, switch, break, continue
  • ๐Ÿงฎ Arithmetic, logic, and comparison operators
  • ๐Ÿงฑ Facets (structs) and type aliases (Refraction)
  • ๐Ÿงต Function declarations, closures, and return values
  • ๐Ÿ“ฆ Arrays with method-style operations (push, pop, indexing)
  • ๐Ÿ”ฆ Function types (Function([T], T) or (T) -> T) for higher-order programming
  • ๐ŸŒŒ Modular system using Constellation and import

๐Ÿงช Primitive Types in Lux

Lux Type Conventional Equivalent Purpose "Why This Name?"
Light int/float Numeric values (all sizes) Fundamental energy โ€” numbers as the measurable force
Lumens string Textual data Measured brightness โ€” strings as visible communication
Umbra void/nil/null Absence of value The deepest shadow โ€” no light, no value
Photon bool Truth values (true/false) Quantum particle of light โ€” binary truth
[T] Array<T> Homogeneous collections A spectrum of values bound by the same light
Function([T], T) fn(T) -> T Function that takes T and returning T A beam directed โ€” computation shaped with intention

๐Ÿงช Examples

// Numeric and string
let x: Light = 42;
let name: Lumens = "Lux";

// Boolean logic
let isBright: Photon = true && false;

// Array
let numbers: [Light] = [1, 2, 3, 4];
emit numbers[2]; // emits 3

// Function type (Lambda)
let greet: () -> Umbra = fn() {
  emit "Hello from Lux!";
};
greet();

// Function definition
fn add(a: Light, b: Light) -> Light {
  return a + b;
}
let sum: Light = add(1, 2);

// Facet (struct)
Refraction Point Facet {
  x Light
  y Light
};

let p: Point = Point { x: 3, y: 4 };
emit p.x + p.y; // emits 7

// Type alias
Refraction Lambda Function([Light, Light], Light)

let add: Lambda = fn(a: Light, b: Light) -> Light {
  return a + b;
};

let sum: Light = add(1, 2);

๐Ÿ›  Installation

Youโ€™ll need Rust installed. Then:

cargo install lux-lang

This will install two CLI tools:

  • lux โ€“ the compiler (produces bytecode)
  • prism โ€“ the virtual machine (runs bytecode)

๐Ÿš€ Getting Started

Create a file called hello.lux:

constellation main;

fn Prism() {
  emit "Hello, world!";
}

Then compile and run it:

lux hello.lux

Or compile and run it with Prism manually:

lux hello.lux -o hello.prism
prism hello.prism

Made with โ˜€๏ธ โ€” Post Tenebras Lux

Commit count: 22

cargo fmt