buzz

buzz

A small/lightweight statically typed scripting language

Guide Reference Try it Latest release open in new window

Statically typed

Find bugs in your IDE rather than production

JIT compiled

Uses MIR, a fast and lightweight JIT compiler

Unambiguous

No implicit behavior or unexpected type coercion

Small in size and complexity

Does not take much space on your drive or in your mind

Interoperability with C

Call C functions easily with FFIs and embed buzz with its C API

Fibers

Single-threaded cooperative multitasking

import "buzz:std";

enum State { todo, doing, done }

object Task {
    title: str,
    points: int?,
    state: State = .todo,

    fun score() => match (this.state) {
        .done -> this.points ?? 0,
        .doing, .todo -> 0
    };
}

fun scores(tasks: [Task]) > str *> int? {
    foreach (task in tasks) {
        _ = yield task.score();
    }
    return "scored {tasks.len()} tasks";
}

fun main() > void {
    final tasks: [Task] = [
        .{ title = "parser", points = 8, state = .done },
        .{ title = "lsp", points = 5, state = .doing },
        .{ title = "docs", points = 3 },
    ];

    var total = 0;
    final fiber = &scores(tasks);
    foreach (score in fiber) {
        total += score ?? 0;
    }

    std\print("completed points: {total}, message is {resolve fiber}");
}