Author:
GARCIA RONALD,JARVI JAAKKO,LUMSDAINE ANDREW,SIEK JEREMY,WILLCOCK JEREMIAH
Abstract
AbstractMany modern programming languages support basic generics, sufficient to implement type-safe polymorphic containers. Some languages have moved beyond this basic support, and in doing so have enabled a broader, more powerful form of generic programming. This paper reports on a comprehensive comparison of facilities for generic programming in eight programming languages: C++, Standard ML, Objective Caml, Haskell, Eiffel, Java, C# (with its proposed generics extension), and Cecil. By implementing a substantial example in each of these languages, we illustrate how the basic roles of generic programming can be represented in each language. We also identify eight language properties that support this broader view of generic programming: support for multi-type concepts, multiple constraints on type parameters, convenient associated type access, constraints on associated types, retroactive modeling, type aliases, separate compilation of algorithms and data structures, and implicit argument type deduction for generic algorithms. We find that these features are necessary to avoid awkward designs, poor maintainability, and painfully verbose code. As languages increasingly support generics, it is important that language designers understand the features necessary to enable the effective use of generics and that their absence can cause difficulties for programmers.
Publisher
Cambridge University Press (CUP)
Cited by
27 articles.
订阅此论文施引文献
订阅此论文施引文献,注册后可以免费订阅5篇论文的施引文献,订阅后可以查看论文全部施引文献
1. Types;Texts in Computer Science;2022
2. Thriving in a crowded and changing world: C++ 2006–2020;Proceedings of the ACM on Programming Languages;2020-06-12
3. How C++ Templates Are Used for Generic Programming;ACM Transactions on Software Engineering and Methodology;2020-02-05
4. Apla Generic Constraint Matching Detection and Verification;2019 24th International Conference on Engineering of Complex Computer Systems (ICECCS);2019-11
5. COCHIS: Stable and coherent implicits;Journal of Functional Programming;2019