Hive
A compiled language for distributed systems, in which what would crash does not compile.
Hive is my main project: a small language I designed and built. There is no null, nothing is thrown, and every index is proved in range before the program runs. It compiles to Go and ships as a single native executable. It is young — not yet 1.0 — and its tour covers the whole language in 74 short slides.
- No crashes in production No null, no exceptions, no out-of-range index: what would crash elsewhere does not compile.
- One process or many machines Services keep their state behind a mailbox, so nothing needs a lock, and calling one across the network looks exactly like calling one locally.
- Runs everywhere The same code on Windows, Linux, macOS, the browser, a container and Android.
Every index is proved in range before the program runs · tour, slide 18
proc main(): void {
v := ["a", "b", "c"]
echo v[len(v) - 1]
}
proc main(): void {
v := ["a", "b", "c"]
last := len(v) - 1
if v bounds last {
echo v[last]
}
}
Refused at compile time
guard.hive:1: in `main`: cannot prove this index is in range: it is a computed expression, and there is nothing to hang a guard on. Bind it to a name first, then guard thatCompiles: the guard proves the index
cA JWT is a codec: sign a value of your own type, and check it before reading it back · tour, slide 60
type Claims { user: Str }
proc main(): void {
if hide(hive.crypto.randomHex(32)) is Result.Ok(key) {
jwt := hive.crypto.jwtCodec(key)
token := encode(Claims("ada"), jwt)
// Checks the signature and the times, then reads the claims.
if Claims.decode(token, jwt) is Result.Ok(claims) {
echo claims.user
}
}
}
Signed, checked and read back
ada“Only HS256 is accepted, which closes the classic algorithm-confusion attack outright.” (slide 60)
type Note {
Say { text: Str }
Heard { count: Int }
}
// One message at a time: no lock, wherever it runs.
proc inbox(count: mut Int, note: Note): Note {
count += 1
return Note.Heard(count)
}
proc main(): void {
if hive.syslink.listen("10.0.0.1:9100") is Result.Error(e) {
panic e
}
spawn(inbox, 0, #Inbox)
there := at("10.0.0.2:9100", #Inbox) // on another machine
echo there(Note.Say("hi"))
}
Run it on both machines
On the second one, swap the two addresses. A node is identified by where it can be reached, so nothing else about the two processes differs.
Calling the service over there is the same line as calling one here, and messages between two nodes arrive in the order they were sent. “Every connection between two nodes is TLS 1.3, mutually authenticated” (slide 59).
An interface is a value: a tree of widgets, served as a page or shown in a window · tour, slides 64 and 65
proc main(): void {
view := hive.ui.column([hive.ui.pad(24), hive.ui.gap(12)], [
hive.ui.text([hive.ui.heading(1)], "Hive Tour"),
hive.ui.row([hive.ui.gap(8)], [
hive.ui.input([hive.ui.placeholder("your name")], ""),
hive.ui.button([hive.ui.tone(hive.ui.Tone.Good())], "Say hi"),
]),
])
// a whole document, served directly
body := hive.ui.page("Hive", view)
echo len(body)
}
Roughly how hive.ui draws it
“Because a view is a value, an interface is testable without a browser” (slide 64).
Four small programs adapted from the Hive tour. The first comes in a form the compiler refuses and a form it accepts; its message is hive check’s own, quoted from slide 70.
Other projects
WebProxy
Web-based distributed cache engine.
View on GitHubDatabase
DETS/ETS-based embedded database for Gleam.
View on HexSlopmachine
Toy research-focused general-purpose AI agent that turned out surprisingly functional.
View on GitHubTechnologies I work with
Press one: each changes the page.
The sky above
Six Tupi-Guarani constellations are drawn in this page’s sky. They were recorded among the Tupinambá by Claude d’Abbeville in 1614 and mapped again by the astronomer Germano Afonso with Guarani communities. Sweep across the stars to light them, or pick one below.
Six figures pick one to bring it forward
Each is traced from Germano Afonso’s charts. The Rhea is a dark constellation, drawn in the gaps of the Milky Way as much as in its stars.
Guyra Nhandu the Rhea
A dark constellation: her head is the Coalsack nebula. She stands tall, beak raised, both three-toed feet stepping to the left and her tail curled low at the right, with α and β Centauri shining inside her body.
Curuxu the Southern Cross
Just above and to the right of the Rhea’s head, holding it shut.
Tuya’i the Old Man
A triangular head in the Hyades, on Aldebaran; a plume reaching the Pleiades; a raised arm and one line to Betelgeuse. His good leg bends at the Three Marys, the stars of Orion’s belt, and his severed leg is drawn dashed down to Rigel.
Eixu the Wasps’ Nest, the Pleiades
The same cluster that tips the Old Man’s plume. The two were named as separate constellations, so the nest sits on that point, with a few stray wasps around it.
Tapi’i the Tapir
She walks the far end of the Milky Way, low by the horizon: snout on the bright star by the nebula, ears pricked, hind legs trailing behind her.
Guaxu the Deer
On the Milky Way just ahead of the Rhea, leaping the same way she runs: muzzle raised, antler swept back, all four legs trailing mid-stride.