Hew
실패를 예상하는 언어.
Hew는 actor 기반 프로그램을 네이티브 코드로 컴파일합니다. 각 actor는 자신의 상태를 소유하고, supervisor는 실패한 actor의 재시작 방식을 결정합니다.
상태는 actor 안에 머뭅니다
이 session actor는 메시지 vector를 소유합니다. post만 vector를 변경하며, 각 호출은 handler가 끝날 때까지 기다린 뒤 Result를 반환합니다.
count는 같은 비공개 상태를 읽어 caller에게 값을 돌려줍니다. 호출이 끝나기 전에 actor가 멈출 수 있으므로 오류 분기도 코드에 남아 있습니다.
// 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"),
}
}$ curl -fsSL https://hew.sh/install | bash -s -- --version 0.9.3$ curl -fsSL https://hew.sh/install | bash -s -- --version 0.9.3> Invoke-WebRequest https://hew.sh/install.ps1 -OutFile install.ps1
.\install.ps1 -Version 0.9.3언어가 명시적으로 드러내는 것
v0.9.3에서 사용할 수 있는 actor, supervision, 동시성, wire 기능입니다.
- 호출자:
chat.post("hello"). 핸들러의 결과를 기다림. - 메일박스:
post("hello"). - 한 번의 핸들러 실행:
messages.push(text). 비공개 상태:messages: ["hello"]. - 호출 결과 → 호출자.
post 호출이 성공하면 Session의 비공개 상태를 갱신한 뒤 결과를 반환합니다.
액터 격리
모든 액터는 자신의 상태를 독점적으로 소유합니다. 컴파일러는 로컬 액터 경계와 Send 검사를 강제합니다.
감독 트리
서비스는 실패합니다. Hew는 그것을 전제로 합니다. 감독자 액터, 재시작 예산, 핵심 재시작 전략은 별도 프레임워크가 아니라 언어 자체의 일부입니다.
구조적 동시성
scope는 자식 작업의 범위를 정하고 반환 전에 완료를 기다립니다. fork는 나중에 합칠 수 있는 독립 actor 호출을 시작합니다.
와이어 계약
와이어 타입은 스키마, 필드 태그, 호환성 검사를 언어 안에 넣고, 그것을 보내는 액터와 함께 다룹니다.
엔지니어링 저널
Hew 0.6.2: safer values, steadier services Edit parsed configuration without changing its source value, then see how Hew 0.6.2 carries the same actor reference across local and remote services. 2026년 10월 21일블로그 읽기 → EN
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