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.
翻译:系统编程语言传统上在物理透明性与编译时内存安全之间存在矛盾。C++提供直接且零成本的硬件访问,但缺乏严格的安全性边界;而Rust虽能保障安全性,却以复杂的生命周期标注和隐式解引用链为代价。本文提出Toka——一种原生系统编程语言,通过显式资源语义在资源管理中建立物理透明性。Toka设计的核心是“句柄-灵魂二元性”(非正式称为“帽子-灵魂模型”),该模型在语法层面明确区分指针标识(句柄)与其底层值(灵魂)。通过强制裸标识符始终表示值(灵魂),而显式符号表示指针句柄,Toka消除了重绑定操作与值修改之间的语义歧义。本文详细阐述了Toka的资源形态(支持唯一、共享、借用和原始语义)、其生命周期检查机制,以及原型编译器的实现。评估表明,Toka在显著降低生命周期标注认知开销的同时,实现了具有竞争力的运行时性能和极小的二进制体积。