cobra4 promotes patterns common in cloud automation, data pipelines, and distributed jobs to first-class language constructs. One line of cobra4 often replaces a small Python program.
Three lines that show what cobra4 is¶
1. ETL across formats — read/save are smart-dispatched¶
rows = read("./users.csv")
adults = each r in rows where int(r["age"]) >= 18 { r }
save(adults, "./adults.json")
2. Webhook server, with auth and pattern-matched routing¶
fn handler(req) {
if req?.headers?.authorization != "Bearer secret" {
return (401, {}, {"error": "nope"})
}
match (req.method, req.path) {
case ("GET", "/health") { return {"ok": true} }
case ("POST", "/users") { return create_user(req.json()) }
case _ { return (404, {}, {}) }
}
}
serve handler on :8080
3. Scheduled job + parallel fan-out¶
urls = read("./targets.txt")
every 5 minutes {
results = each url in urls in parallel(workers=10) { fetch(url) }
save(results, "s3://bucket/snapshots/{now()}.jsonl")
}
Mantra¶
- Readability first — no esoteric operators (no
|>), English keywords. - One line = one program — cloud / distributed patterns are syntax.
- General-purpose — anything Python does, cobra4 does.
- Extensible on two axes — libraries extend the runtime,
language plugins (
lang use sql) extend the parser/AST.
