Lux Quickstart Guide
Get from zero to running Lux code in 5 minutes.
Install
# From the joulesperbit workspace β builds the `lux` binary:
cargo build --release -p lux-cli
# The canonical formatter is a separate binary:
cargo build --release -p lux-fmt
# Add both to PATH:
export PATH="$PWD/target/release:$PATH"
# Verify:
lux version
# β Lux v0.1.0
Hello World
Create hello.lux:
fn main():
print("Hello, world!")
Run it:
lux run hello.lux
# β Hello, world!
# Energy: 0.0023 J | 847 ops | 0.12 W
Every execution produces an energy receipt β joules consumed, operations counted, watts drawn.
Create a Project
lux new my-app
cd my-app
This creates:
my-app/
βββ joule.toml # Project manifest
βββ src/
β βββ main.lux # Entry point
βββ tests/
βββ main_test.lux
joule.toml
[project]
name = "my-app"
version = "0.1.0"
entry = "src/main.lux"
[build]
target = "native" # or "wasm"
Language Basics
Variables and Types
let name = "Lux" # Inferred as str
let mut count = 0 # Mutable integer
let ratio: float = 3.14 # Explicit type
let items: [int] = [1, 2, 3] # Typed list
Functions
fn greet(name: str) -> str:
"hello {name}"
fn add(a: int, b: int) -> int = a + b # Expression body
Control Flow
if score > 90:
print("excellent")
else:
print("keep going")
for item in items:
print(item)
match status:
"ok" => handle_ok()
"error" => handle_error()
_ => handle_unknown()
Apps (Full-stack UI)
app Counter:
let mut count = signal(0)
view:
h1 "Counter: {count}"
button @click={count += 1} "+"
button @click={count -= 1} "-"
Servers
server Api port=8080:
get "/health":
respond {status: "ok"}
post "/echo":
let body = request.body
respond body
Styles
style card:
background = "#fff"
padding = "16px"
border_radius = "8px"
box_shadow = "0 2px 4px rgba(0,0,0,0.1)"
Pattern Matching
fn describe(value):
match value:
0 => "zero"
1..10 => "small"
n if n > 100 => "large: {n}"
_ => "other"
Pipe Operator
let result = data
|> filter(x => x > 0)
|> map(x => x * 2)
|> sum()
CLI Commands
| Command | Description |
|---|---|
lux run [file] | Execute a .lux file via the interpreter (reads joule.toml if omitted) |
lux new <name> | Create a new project |
lux check <file> | Parse and type-check without running |
lux test [path] | Run test blocks in .lux files |
lux build [path] | Compile (native / --wasm / HTML / JS / PWA; --release for optimized) |
lux dev [path] | JIT dev server with hot reload (port 3000) |
lux repl | Interactive REPL (multi-line, history) |
lux lift <path> | Analyze foreign code (14 languages) for energy waste |
lux lift --convert | Convert foreign code to .lux |
lux audit [path] | Energy audit any codebase (dozen-plus detectors) |
lux pyinstall <pkg> | Install Python packages from PyPI |
lux add <pkg> / remove / install | Manage dependencies in joule.toml |
lux list | Show available modules |
lux serve / remote / tui | IDE server, SSH tunnel to a remote IDE, terminal UI |
Formatting is a separate binary,
lux-fmt(not alux fmtsubcommand):lux-fmt [files...]formats in place;--checkverifies;--stdinreads stdin β stdout;lux-fmt .recurses.
Energy Auditing (No Migration Required)
Audit existing code without converting anything:
# Audit a JavaScript project
lux audit ./my-js-app
# JSON output for CI pipelines
lux audit ./src --format json
# Only critical issues
lux audit . --severity critical
Output:
Energy Audit Report
βββββββββββββββββββ
Files scanned: 47
Languages: JavaScript (32), TypeScript (12), Python (3)
CRITICAL N+1 query in loop src/api/users.js:42 ~100x waste
HIGH O(nΒ²) nested loop src/utils/sort.js:18 ~10x waste
MEDIUM String concat in loop src/render.js:95 ~5x waste
Standard Library
Lux ships 1,723 modules β no package manager needed for common tasks:
use lux:http # HTTP client/server
use lux:json # JSON parse/serialize
use lux:crypto # Hashing, encryption
use lux:chart # Data visualization
use lux:math # Math functions
use lux:regex # Regular expressions
use lux:websocket # WebSocket client/server
use lux:test # Testing framework
Run lux list to see all available modules.
Editor Setup
VSCode
- Build the LSP:
cargo build --release -p lux-lsp - Point your editorβs Lux extension at the
lux-lspbinary. - Reload the editor.
Features: diagnostics (parse-on-change), completion (keywords, types, modules, builtins), hover docs, go-to-definition.
MCP (AI Integration)
cargo build --release -p lux-mcp
Add to your MCP client config (Claude Code, Cursor, etc.):
{
"mcpServers": {
"lux": {
"command": "/path/to/lux-mcp"
}
}
}
Tools available: lux_run, lux_check, lux_audit, lux_lift, lux_modules, lux_docs.
Testing
test "addition works":
assert add(2, 3) == 5
test "greeting includes name":
let result = greet("Lux")
assert result == "hello Lux"
lux test
# β addition works (0.0001 J)
# β greeting includes name (0.0001 J)
# 2 tests passed | 0.0002 J total
Whatβs Next
- Read the full Language Specification
- Read the Whitepaper on energy-efficient computing
- Browse the standard library modules (1,723 modules)
- Try
lux auditon your existing codebase β no commitment required
Lux v0.1.0 β Open Interface Engineering, Inc. β March 2026