Programmers learning Rust struggle to understand ownership types, Rust's core mechanism for ensuring memory safety without garbage collection. This paper describes our attempt to systematically design a pedagogy for ownership types. First, we studied Rust developers' misconceptions of ownership to create the Ownership Inventory, a new instrument for measuring a person's knowledge of ownership. We found that Rust learners could not connect Rust's static and dynamic semantics, such as determining why an ill-typed program would (or would not) exhibit undefined behavior. Second, we created a conceptual model of Rust's semantics that explains borrow checking in terms of flow-sensitive permissions on paths into memory. Third, we implemented a Rust compiler plugin that visualizes programs under the model. Fourth, we integrated the permissions model and visualizations into a broader pedagogy of ownership by writing a new ownership chapter for The Rust Programming Language, a popular Rust textbook. Fifth, we evaluated an initial deployment of our pedagogy against the original version, using reader responses to the Ownership Inventory as a point of comparison. Thus far, the new pedagogy has improved learner scores on the Ownership Inventory by an average of 9% ($N = 342, d = 0.56$).
翻译:学习Rust的程序员难以理解所有权类型——这一无需垃圾回收即可确保内存安全的核心机制。本文描述了我们在系统化设计所有权类型教学法方面的尝试。首先,我们通过研究Rust开发者对所有权概念的误解,创建了所有权清单这一测量个体所有权知识的新工具。我们发现Rust学习者难以将Rust的静态与动态语义联系起来,例如判断类型错误的程序是否(或为何不会)表现出未定义行为。其次,我们构建了Rust语义的概念模型,该模型通过内存路径上基于流敏感权限来解释借用检查。第三,我们实现了基于该模型对程序进行可视化的Rust编译器插件。第四,我们将权限模型与可视化整合到更广泛的所有权教学中,为流行Rust教材《The Rust Programming Language》编写了新的所有权章节。第五,我们通过对比读者对所有权清单的反馈,评估了新教学法相较于原版的首批部署效果。迄今为止,新教学法使学习者在所有权清单上的得分平均提升了9%(N=342,d=0.56)。