Core Concepts
Build a useful mental model first; follow the details when your program needs them.
Hew programs are made from familiar values and functions, plus actors that own long-lived state. A few terms describe how those pieces fit together. You do not need to learn the vocabulary before writing Hew: start with the question your program raises, then follow the relevant concept.
Start with your question
Who owns this value?
Understand ordinary values, moves, cloning, deterministic cleanup, and what “affine” means in Hew.
Actors and messagesWhat crosses an actor boundary?
See how actor isolation, Send, snapshots, affine transfers, and call outcomes work together.
Who starts, stops, and restarts an actor?
Follow an actor from construction through handlers and cleanup, then add supervision for recovery.
Concurrent workHow long may a task run?
Use scope, fork, await, deadlines, and cancellation without losing track of child work.
The model in one pass
- Values have owners. Ordinary data can provide an independent logical value when reused. An affine value has one live owner and transfers instead.
- Actors own mutable state. One handler at a time can reach an actor's state, so callers interact through typed messages rather than shared mutation.
- Actor boundaries preserve isolation. Ordinary message data arrives as a snapshot. A sendable affine resource moves to the receiver. The compiler derives and checks
Send. - Tasks belong to a lifetime.
forkstarts child work,awaittakes its result, and the owning scope settles every child before it exits. - Actors have independent lifetimes. Calling an actor does not make it a child task. Use
stop,stopped, and supervisors to manage actor lifetime and recovery.
A small glossary
- Actor
- An independently scheduled component that owns state and handles one message at a time.
- Actor handle
- A typed value used to call an actor. It names the actor; it does not expose the actor's fields.
- Ownership
- The rules that decide who is responsible for a value and when its cleanup runs.
- Affine value
- A value with at most one live owner. It may be moved or consumed, but it cannot be duplicated without a type-specific clone contract.
Send- A compiler-derived marker saying a type can safely cross an actor boundary. It says the crossing is safe, not whether the runtime copies, retains, or moves storage.
- Snapshot
- The independent logical value an actor receives for ordinary message data. Later mutation by one actor cannot change the other's value.
- Task
- A concurrent computation created by
forkand owned by a structured lifetime. - Scope
- A boundary that settles its child tasks and cleanup before producing its value.
- Supervisor
- An owner of child actor roles that applies restart policies and limits repeated failure.
- Authority
- The ability to perform an operation, such as reading a particular file. Hew can make that access explicit by supplying a narrow service or resource.
Choose the depth you need
- Learn by building: use the actor-based key-value store tutorial or the interactive lessons.
- Understand the model: read these concept pages, then the actor guide, authority confinement guide, or state-machine guide for the part you are designing.
- Check exact syntax and contracts: use the language reference, standard-library guide, the released language and API reference, and the specification linked above.
Related ideas in other systems
These resources explain broader ideas that influenced the field. Their syntax and rules are specific to their own languages; use the Hew pages above for Hew semantics.
- The Rust Book: Understanding Ownership — an approachable introduction to ownership-based memory management. Hew has different borrowing and value rules.
- The Swift Programming Language: Concurrency — a broader treatment of parent-child tasks and structured concurrency.
- Erlang/OTP supervision principles — the established model behind supervision trees and restart intensity.
- Pony reference capabilities — an advanced comparison for compile-time actor isolation; Pony's capability system is not Hew's type system.