🤖 AI Summary
Actor-based systems (e.g., Erlang/OTP) suffer from runtime protocol violations and production failures due to the absence of static type guarantees in message protocols. This paper introduces NVLang, a novel statically typed language targeting the BEAM virtual machine, which enables end-to-end compile-time verification of message protocols in the Actor model for the first time. Its core contributions are: (1) modeling message protocols naturally via algebraic data types; (2) introducing typed process identifiers (Pid[T]) and typed futures (Future[T]) to enforce bidirectional type contracts between communicating actors; and (3) extending Hindley–Milner type inference to precisely track protocol state across process boundaries. NVLang compiles to Core Erlang and maintains full interoperability with the Erlang ecosystem. Evaluation demonstrates that our approach eliminates the vast majority of runtime message errors while preserving syntactic concision and seamless interoperation—guaranteeing that well-typed programs never violate Actor communication protocols.
📝 Abstract
Actor-based systems like Erlang/OTP power critical infrastructure -- from telecommunications to messaging platforms--handling millions of concurrent connections with legendary reliability. Yet these systems lack static guarantees about message protocols: processes communicate by sending arbitrary messages that pattern-matched at runtime, deferring protocol violations to production failures.
We present NVLang, a statically typed functional language that brings comprehensive type safety to the BEAM virtual machine while preserving actor model's simplicity and power. NVLang's central contribution that algebraic data types (ADTs) naturally encode actor message protocols: each actor declares the sum type representing its message vocabulary, and the type system enforces protocol conformance at compile time. We introduce typed process identifiers (Pid[T]) that encode the protocol an actor expects, and typed futures (Future[T]) that provide type-safe request-reply patterns.
By extending Hindley-Milner type inference to track message protocols, NVLang eliminates an entire class of message-passing errors while maintaining clean syntax that rivals dynamically typed alternatives. Our implementation compiles to Core Erlang, enabling seamless interoperability with the existing Erlang ecosystem. We formalize the type system and provide proof sketches for type soundness, demonstrating that well-typed NVLang programs cannot send messages that violate actor protocols.