Skip to content

mac-agent/luzlang

 
 

Repository files navigation

Luz logo

Luz Programming Language

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")
}

Features

  • Dynamic typing — integers, floats, strings, booleans, lists, dictionaries, null
  • Format strings$"Hello {name}, you are {age} years old!"
  • Control flowif / elif / else, while, for (range and for-each), switch, match
  • Ternary operatorvalue if condition else other
  • Functions — default parameters, variadic (...args), multiple return values, closures
  • Lambdasfn(x) => x * 2 and fn(x) { body } as first-class values
  • Dot method syntax"hello".uppercase(), list.append(x), list.contains(x)
  • Bound methodsm = obj.method stores the method with self already bound
  • Compound assignment+=, -=, *=, /=
  • Destructuring assignmentx, y = func()
  • Negative indexinglist[-1], str[-2]
  • Object-oriented programming — classes, inheritance (extends), method overriding, super
  • Error handlingattempt / rescue / finally blocks and alert
  • Modulesimport, from "x" import name, import "x" as alias
  • Package managerRay, installs packages from GitHub
  • Standard libraryluz-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

Quick start

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 file

Or download the Windows installer and run luz from anywhere.

Language at a glance

# 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")
}

Package manager — Ray

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 package

Standard library

luz-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

VS Code extension

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

Documentation

Full language reference, built-in functions, and architecture guide: elabsurdo984.github.io/luz-lang

License

MIT — see LICENSE for details.

About

Luz is a modern, expressive programming language. Simple syntax, powerful features, built in Python.

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • Python 84.5%
  • C 14.5%
  • Other 1.0%