Toka: A Systems Programming Language with Explicit Resource Semantics

2026-06-01Programming Languages

Programming Languages
AI summary

The authors created a new programming language called Toka that aims to make it easier to manage memory safely while still being close to the hardware, like C++ but safer like Rust. Toka uses a novel approach called Handle-Soul Duality, which clearly separates pointers (Handles) from the actual data (Souls), helping programmers avoid confusing mistakes. Their system supports different ways of handling resources and checks lifetimes to prevent errors, all while keeping code simpler and performance competitive. They also built a prototype compiler to show these ideas work in practice.

systems programmingmemory safetyHandle-Soul Dualityresource managementlifetime checkingcompile-time safetypointersRustC++compiler
Authors
Zhonghua Yi
Abstract
Systems programming languages traditionally struggle with the tension between physical transparency and compile-time memory safety. C++ provides direct, zero-cost hardware access but lacks strict safety boundaries, whereas Rust guarantees safety at the cost of complex lifetime annotations and implicit dereferencing chains. In this paper, we present Toka, a native systems programming language that establishes physical transparency in resource management via Explicit Resource Semantics. At the core of Toka's design is the Handle-Soul Duality (informally referred to as the Hat-Soul model), which cleanly dissociates pointer identities (Handles) from their underlying values (Souls) at the syntactic level. By enforcing that bare identifiers always represent values (Souls) and explicit sigils represent pointer handles, Toka eliminates the semantic ambiguity between rebind operations and value mutations. We detail Toka's resource morphology (supporting unique, shared, borrowed, and raw semantics), its lifetime checking mechanism, and its implementation of a prototype compiler. Our evaluation demonstrates that Toka achieves competitive runtime performance and minimal binary size while drastically reducing the cognitive overhead of lifetime annotations.