I present Vanilla Object Orientation (VOO), a framework that composes classes from Tcl's native data structures -- lists and dictionaries -- rather than introducing additional framework infrastructure. VOO objects are plain Tcl lists with automatic memory management through copy-on-write semantics, eliminating the destructor burden inherent in TclOO and Itcl. Benchmarks on Tcl 8.6.13 and Tcl 9.0 show VOO achieves 7--18x faster object creation and 4--6x superior memory efficiency compared to TclOO. A companion C++ migration path (VOO C++) further improves field-access speed (setter 2.3--2.6x faster) and memory (6.8--9.8x lighter than TclOO), while preserving an identical Tcl call-site API. Cross-version analysis confirms that VOO's compositional design scales better than framework-based approaches as the interpreter evolves.
翻译:本文提出原生面向对象(Vanilla Object Orientation,VOO)框架,该框架利用Tcl原生数据结构(列表与字典)构建类,无需引入额外的框架基础设施。VOO对象作为纯Tcl列表存在,通过写时复制语义实现自动内存管理,消除了TclOO和Itcl中固有的析构器负担。基于Tcl 8.6.13与Tcl 9.0的基准测试表明,相较于TclOO,VOO对象创建速度提升7-18倍,内存效率提升4-6倍。配套的C++迁移路径(VOO C++)进一步优化了字段访问速度(setter提速2.3-2.6倍)与内存效率(比TclOO轻量6.8-9.8倍),同时保持与Tcl完全一致的调用端API。跨版本分析证实,随着解释器演进,VOO的组合式设计比基于框架的方法具有更优的可扩展性。