Luz is an open-source, interpreted programming language written in Python. It features clean syntax, object-oriented programming, closures, pattern matching, error handling, and a built-in package manager — all in a single file you can run with python main.py.
name = listen("What is your name? ")
write($"Hello {name}!")
for i = 1 to 5 {
write("even" if even(i) else "odd")
}
- Dynamic typing — integers, floats, strings, booleans, lists, dictionaries,
null - Format strings —
$"Hello {name}, you are {age} years old!" - Control flow —
if / elif / else,while,for(range and for-each),switch,match - Ternary operator —
value if condition else other - Functions — default parameters, variadic (
...args), multiple return values, closures - Lambdas —
fn(x) => x * 2andfn(x) { body }as first-class values - Dot method syntax —
"hello".uppercase(),list.append(x),list.contains(x) - Bound methods —
m = obj.methodstores the method withselfalready bound - Compound assignment —
+=,-=,*=,/= - Destructuring assignment —
x, y = func() - Negative indexing —
list[-1],str[-2] - Object-oriented programming — classes, inheritance (
extends), method overriding,super - Error handling —
attempt / rescue / finallyblocks andalert - Modules —
import,from "x" import name,import "x" as alias - Package manager — Ray, installs packages from GitHub
- Standard library —
luz-math,luz-random,luz-io,luz-system,luz-clock - Helpful errors — every error includes the line number
- REPL — interactive shell for quick experimentation
- VS Code extension — syntax highlighting, autocompletion, error detection, hover docs, snippets
- Standalone installer — no Python required
Requires Python 3.8+, no external dependencies.
git clone https://github.com/Elabsurdo984/luz-lang.git
cd luz-lang
python main.py # open the REPL
python main.py file.luz # run a fileOr download the Windows installer and run luz from anywhere.
# Default parameters and variadic functions
function greet(name, greeting = "Hello") {
write($"{greeting}, {name}!")
}
function sum(...nums) {
total = 0
for n in nums { total += n }
return total
}
greet("Alice") # Hello, Alice!
greet("Bob", "Hi") # Hi, Bob!
write(sum(1, 2, 3, 4)) # 10
# Multiple return values + destructuring
function min_max(a, b) {
if a < b { return a, b }
else { return b, a }
}
lo, hi = min_max(8, 3)
# Ternary operator
label = "even" if even(lo) else "odd"
# Switch statement
switch lo {
case 0 { write("zero") }
case 1, 2, 3 { write("small") }
else { write("other") }
}
# Match expression
result = match hi {
8 => "eight"
_ => "something else"
}
# Dot method syntax — strings and lists
words = "hello world".split(" ") # ["hello", "world"]
words.append("!")
write(words.join(", ")) # hello, world, !
write(words.contains("hello")) # true
# Object-oriented programming + bound methods
class Counter {
function init(self) { self.n = 0 }
function inc(self) { self.n += 1 }
function get(self) { return self.n }
}
c = Counter()
step = c.inc # bound method — self already attached
step()
step()
write(c.get()) # 2
# Error handling
attempt {
result = 10 / 0
} rescue (e) {
write($"Caught: {e}")
} finally {
write("done")
}
Ray installs Luz packages from GitHub into luz_modules/:
ray init # create luz.json
ray install user/repo # install a package
ray list # list installed packages
ray remove package-name # remove a packageluz-math and luz-random are bundled with the installer:
import "math"
import "random"
write(PI) # 3.14159265358979
write(factorial(10)) # 3628800
write(rand_int(1, 100)) # random integer
write(choice(["a","b","c"])) # random element
Install from the vscode-luz/ folder for full language support:
- Syntax highlighting
- Autocompletion — keywords, built-ins, user-defined symbols
- Error detection — syntax errors underlined on save
- Hover documentation
- Snippets
Full language reference, built-in functions, and architecture guide: elabsurdo984.github.io/luz-lang
MIT — see LICENSE for details.