Introduction to Logos
Logos is a scripting language designed for clarity. When Bash scripts grow past a few dozen lines, Logos is what you reach for — readable syntax, proper error handling, and code you'll still understand next month.
Why Logos?
Bash is fine for one-liners. But as scripts grow, they become unreadable. Logos solves this with:
- Readable syntax — C-like structure that reads like English prose, not line noise
- Sane error handling — Functions return result objects. Check
.ok, handle.error. No silent failures. - Batteries included — File I/O, HTTP, JSON, shell execution all work without imports
- Concurrency —
spawnblocks run tasks in parallel when order doesn't matter - Compile to binary —
lgs build script.lgsproduces a standalone executable - Embed in Go — Integrate into your Go applications like Lua or JavaScript
A Taste of Logos
Here's a script that reads a config file, parses JSON, uses string interpolation, and runs tasks concurrently:
// Fetch config, handle errors gracefully
let res = fileRead("config.json")
if !res.ok {
print(colorRed("Error: " + res.error))
exit(1)
}
let config = try parseJson(res.value)
// String interpolation makes templates readable
let greeting = "Hello, ${config["name"]}! Your plan: ${config["plan"]}"
// Ternary for simple conditions
let status = config["active"] ? "active" : "inactive"
print("${status} - ${greeting}")
// Dot assignment mutates table fields
config["version"] = "2.0"
// For-in with index for numbered lists
let tasks = ["build", "test", "deploy"]
for i, task in tasks {
print("${i + 1}. ${task}")
}
// Range with step (0 to 10, exclusive)
for i in range(0, 10, 2) {
print(i) // 0, 2, 4, 6, 8
}
// Run tasks concurrently when order doesn't matter
spawn for task in tasks {
processTask(task)
}CLI Commands
Run scripts, format code, or build binaries:
lgs hello.lgs # Run a script
lgs fmt script.lgs # Format code (auto-fixes indentation)
lgs build script.lgs # Compile to standalone binary
lgs # Start the REPL for quick experiments