Skip to main content

Hew

Hew compiles actor-based programs to native code. Each actor owns its state, and supervisors decide how failed actors restart.

Read current status Β· GitHub

State stays with the actor

This session actor owns its message vector. post is the only code here that mutates the vector, and each call waits for the handler to finish before returning a Result.

After two posts, count returns the number of messages. The caller prints that number on success, or session unavailable if the call fails.

Read the actor model β†’
session.hew
// A chat session is an actor: state lives in fields and only its handlers
// can mutate it. Ordinary actor calls wait for the handler and return a
// Result, whether or not the handler itself returns a value.
actor Session {
    let user: string;
    var messages: Vec<string> = Vec.new();
    receive fn post(text: string) {
        messages.push(text);
    }
    receive fn count() -> i64 {
        messages.len()
    }
}
 
fn main() {
    let chat = spawn Session { user: "ada", messages: [] };
    chat.post("hello").expect("actor stopped");
    chat.post("world").expect("actor stopped");
    let total = chat.count();
    match total {
        .Ok(n) => println(f"{n} messages posted"),
        .Err(_) => println("session unavailable"),
    }
}

Install Hew

Choose your operating system to see the install command.

v0.11.2 Β· Release

Read the complete installation guide.

What the language makes explicit

Each of these is available in v0.11.2.

A call into Session
  1. Caller: chat.post("hello"). Waits for the handler’s result.
  2. Mailbox: post("hello").
  3. One handler turn: messages.push(text). Private state: messages: ["hello"].
  4. Completion result β†’ Caller.

A successful post updates Session’s private state before returning its result.

Actor Isolation

Only an actor can modify its own fields. The compiler checks which values callers can send to it.

Supervision Trees

A supervisor declares which children to restart after a failure and how many restarts to allow in a given interval.

Structured Concurrency

Use fork to start independent actor calls. Their enclosing scope waits for the child work before it returns.

Wire Contracts

Numeric tags identify fields in a wire type. The compatibility checker compares revisions of the schema.

Engineering Journal

Hew 0.11.2: module-private record fields and faster release builds Keep named record fields private to their declaring module, evict least-recently-used cache entries, and compile large Linux release builds in parallel. Nov 23, 2026
Read the Blog β†’

Hew Notes

Language development, engineering articles, releases and community projects, about once a month, with an extra issue for a significant release. Written in English.

Subscribe to Hew Notes