Lyricdev
GitHub

Lyric: native programs, plainly written.

A statically typed language for applications, command-line tools and servers. It compiles through C to one binary per program, runs its tasks on coroutines with their own stacks, and says in a function's signature what it throws.

Get startedRead the Book

fn handle(req: Request): Response throws Error {
    let path = req.uri.path;
    if (path == "/items" && req.method == Method.Get) {
        return try Response.withJson(items.toArray());
    }
    if (path == "/items" && req.method == Method.Post) {
        let fresh = try req.json<NewItem>();
        let item = Item { id = items.length() + 1, name = fresh.name, price = fresh.price };
        items.push(item);
        var r = try Response.withJson(item, 201);
        r.headers.set("Location", f"/items/{item.id}");
        return r;
    }
    if (path.startsWith("/items/")) {
        let id = try int.parse(path.splitOnce("/items/")!.1);
        for (item in items) {
            if (item.id == id) {
                return try Response.withJson(item);
            }
        }
        return try Response.withJson(Problem { error = f"no item {id}" }, 404);
    }
    return try Response.withJson(Problem { error = f"no {path}" }, 404);
}

Native binaries

A program builds into one executable for Linux, macOS or Windows — no virtual machine to install beside it.

Concurrency without colouring

A task runs on a stack of its own, so any function may wait for input or output; none is marked async.

Errors in the signature

A function names what it throws; a caller handles it or passes it on with try — no error leaves unseen.

The Book

The language from the first program to a server, chapter by chapter.

Standard library

Every module, type and function of std.

Specification

The rules of the language, precisely.