See what your code does. Test without mocks. Ship with confidence.
fn processOrder(order: Order): Receipt with {Database, Email} = {
let saved = Database.save(order)
Email.send(order.customer, "Order confirmed!")
Receipt(saved.id)
}
// The signature tells you EVERYTHING this function does
In most languages, functions can do anything. You can't tell from the signature.
fetchUser(id: Int): User
// Does this call the network?
// Touch the database?
// Write to a file?
// Who knows!
fn fetchUser(id: Int): User
with {Http, Database}
// You KNOW this touches
// network and database
Three pillars that make functional programming practical.
Every function declares its effects in the type signature. No hidden surprises. Refactor with confidence.
fn sendNotification(
user: User,
msg: String
): Unit with {Email, Log} = {
Log.info("Sending to " + user.email)
Email.send(user.email, msg)
}
Swap effect handlers at runtime. Test database code without a database. Test HTTP code without network.
// Production
run app() with {
Database = postgres,
Email = smtp
}
// Test - same code!
run app() with {
Database = inMemory,
Email = collect
}
Compiles to C via gcc/clang. Reference counting with FBIP optimization. Matches Rust and C speed.
Benchmark Lux Rust Go
───────────────────────────────────
fibonacci(40) 0.015s 0.018s 0.041s
ackermann 0.020s 0.029s 0.107s
primes 1M 0.012s 0.014s 0.038s
quicksort 1M 0.089s 0.072s 0.124s
Edit the code and click Run. No installation required.
// Click "Run" to execute
One command to try Lux. Two to build from source.