Context: Generic programming, as defined by Stepanov, is a methodology for writing efficient and reusable algorithms by considering only the required properties of their underlying data types and operations. Generic programming has proven to be an effective means of constructing libraries of reusable software components in languages that support it. Generics-related language design choices play a major role in how conducive generic programming is in practice. Inquiry: Several mainstream programming languages (e.g. Java and C++) were first created without generics; features to support generic programming were added later, gradually. Much of the existing literature on supporting generic programming focuses thus on retrofitting generic programming into existing languages and identifying related implementation challenges. Is the programming experience significantly better, or different when programming with a language designed for generic programming without limitations from prior language design choices? Approach: We examine Magnolia, a language designed to embody generic programming. Magnolia is representative of an approach to language design rooted in algebraic specifications. We repeat a well-known experiment, where we put Magnolia's generic programming facilities under scrutiny by implementing a subset of the Boost Graph Library, and reflect on our development experience. Knowledge: We discover that the idioms identified as key features for supporting Stepanov-style generic programming in the previous studies and work on the topic do not tell a full story. We clarify which of them are more of a means to an end, rather than fundamental features for supporting generic programming. Based on the development experience with Magnolia, we identify variadics as an additional key feature for generic programming and point out limitations and challenges of genericity by property. Grounding: Our work uses a well-known framework for evaluating the generic programming facilities of a language from the literature to evaluate the algebraic approach through Magnolia, and we draw comparisons with well-known programming languages. Importance: This work gives a fresh perspective on generic programming, and clarifies what are fundamental language properties and their trade-offs when considering supporting Stepanov-style generic programming. The understanding of how to set the ground for generic programming will inform future language design.
翻译:Stepanov定义的通用编程: Stepanov 定义的通用编程: 通用编程: 通用编程: 通用编程: 仅考虑其基本数据类型和操作所需的特性, 通用编程: 通用编程已证明是建造图书馆, 以辅助其使用的语文建立可再使用的软件组件的图书馆的有效手段。 通用的语文设计选择在实践上如何有利于通用编程方面起着重要作用。 调查: 几种主流编程语言(如爪哇和C+++)最初在没有通用术语的情况下创建; 支持通用编程的特征后来逐步得到增加。 许多支持通用编程的现有文献都因此侧重于将通用编程改进为现有语文,并找出相关的执行挑战。 通用编程经验是显著的,我们用通用编程的通用编程、从常规编程到基础的编程的编程,我们通过实施Boost 图表图书馆的一组编程,然后通过支持我们的发展经验: 我们发现,通用编程的主要编程特征是用于常规编程,我们之前的编程的编程的编程,我们从一个新的编程到最后的编程的编程,我们用的是最新的编程,我们用的是最新的编程的编程的编程的编程,我们用的是最新的编程的编程,我们用的是最新的编程的编程的编程的编程的编程的编程,我们用的是最新的编程将用的是最新的编程, 。