Luz Language
A lightweight, interpreted programming language designed to be simple, readable, and easy to learn.
No Python required
A taste of Luz¶
name = listen("What is your name? ")
write($"Hello {name}!")
for i = 1 to 5 {
if even(i) {
write($"{i} is even")
} else {
write($"{i} is odd")
}
}
Why Luz?¶
No boilerplate
Variables need no declaration keyword. Blocks use { }.
Readable syntax
Keywords read like English: for i = 1 to 10, attempt / rescue.
Full OOP
Classes, inheritance, method overriding, and super.
First-class functions
Lambdas, closures, and higher-order functions.
Helpful errors
Every error includes the source line number.
Standard library
Math, random, I/O, system, and clock โ all built in.
Quick example¶
class Animal {
function init(self, name) {
self.name = name
}
function speak(self) {
write($"{self.name} says hello!")
}
}
class Dog extends Animal {
function speak(self) {
super.speak()
write("(woof!)")
}
}
d = Dog("Rex")
d.speak()
Features at a glance¶
| Feature | Syntax |
|---|---|
| Variable | x = 10 |
| Null coalescing | x = value ?? "default" |
| Format string | $"Hello {name}" |
| List comprehension | [x * x for x in list] |
| Membership | 3 in [1, 2, 3] |
| String repeat | "ha" * 3 |
| For range | for i = 1 to 10 { } |
| For each | for item in list { } |
| Lambda | fn(x) => x * 2 |
| Class | class Dog extends Animal { } |
| Error handling | attempt { } rescue (e) { } |
| Import | import "math" |