Gossamer

A Rust-like, F# inspired language on a Go like engine.
Compiled or interpreted.

Get started → View Source

Natural functional flow with forward pipes

fn double(x: i64) -> i64 { x * 2 }
fn add(a: i64, b: i64) -> i64 { a + b }
fn clamp(lo: i64, hi: i64, x: i64) -> i64 {
    if x < lo { lo } else if x > hi { hi } else { x }
}

fn main() {
    let n = 3
        |> double
        |> add(10)
        |> clamp(0, 100)
    println("answer:", n)
}

Spin up a web server

use std::http

struct App { }

impl http::Handler for App {
    fn serve(&self, request: http::Request) -> Result<http::Response, http::Error> {
        Ok(http::Response::text(200, "hello, gossamer"))
    }
}

fn main() -> Result<(), http::Error> {
    http::serve("0.0.0.0:8080", App { })
}

True goroutines, colorless functions

Every go fn(args) runs on a real ~16 KiB stackful coroutine on the M:N work-stealing scheduler. Blocking primitives — channel.recv, mutex.lock, time::sleep, network reads, filesystem syscalls — park the goroutine instead of the OS thread, so 10 000 idle goroutines fit on a handful of cores. No async, no await, no function colouring.

use std::time

fn worker(id: i64, tx: chan<i64>) {
    time::sleep(time::Duration::from_millis(10))
    tx.send(id * id)
}

fn main() {
    let (tx, rx) = channel::<i64>()
    for i in 0..10_000 {
        go worker(i, tx.clone())
    }
    let mut total: i64 = 0
    for _ in 0..10_000 {
        total = total + rx.recv()
    }
    println("sum of squares:", total)
}

Supported platforms

Stackful coroutines (corosensei) are wired for: