Revisiting Language Support for Generic Programming: When Genericity is a Core Design Goal
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.
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?
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.
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.
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.
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.
Thu 16 MarDisplayed time zone: Osaka, Sapporo, Tokyo change
14:00 - 15:30
|Primrose: Selecting Container Data Types by their PropertiesVol. 7
Xueying Qin The University of Edinburgh, Liam O'Connor University of Edinburgh, Michel Steuwer University of EdinburghLink to publication
|Revisiting Language Support for Generic Programming: When Genericity is a Core Design GoalVol. 7
Benjamin Chetioui University of Bergen, Norway, Jaakko Järvi University of Turku, Magne Haveraaen University of Bergen, NorwayLink to publication
|Profiling and Optimizing Java StreamsVol. 7
Eduardo Rosales University of Lugano, Switzerland, Matteo Basso Università della Svizzera italiana, Andrea Rosà USI Lugano, Walter Binder USI LuganoLink to publication