Hostname: page-component-89b8bd64d-72crv Total loading time: 0 Render date: 2026-05-06T08:31:35.341Z Has data issue: false hasContentIssue false

An extended comparative study of language support for generic programming

Published online by Cambridge University Press:  01 March 2007

RONALD GARCIA
Affiliation:
Open Systems Lab, Indiana University, Bloomington, IN, USA (e-mail: garcia@osl.iu.edu, lums@osl.iu.edu, jewillco@osl.iu.edu)
JAAKKO JARVI
Affiliation:
Texas A&M University, Computer Science, College Station, TX, USA (e-mail: jarvi@cs.tamu.edu)
ANDREW LUMSDAINE
Affiliation:
Open Systems Lab, Indiana University, Bloomington, IN, USA (e-mail: garcia@osl.iu.edu, lums@osl.iu.edu, jewillco@osl.iu.edu)
JEREMY SIEK
Affiliation:
Rice University, Computer Science, Houston, TX, USA (e-mail: jeremy.g.siek@rice.edu)
JEREMIAH WILLCOCK
Affiliation:
Open Systems Lab, Indiana University, Bloomington, IN, USA (e-mail: garcia@osl.iu.edu, lums@osl.iu.edu, jewillco@osl.iu.edu)
Rights & Permissions [Opens in a new window]

Abstract

Core share and HTML view are not available for this content. However, as you have access to this content, a full PDF is available via the 'Save PDF' action button.

Many 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.

Information

Type
Article
Copyright
Copyright © Cambridge University Press 2006
Submit a response

Discussions

No Discussions have been published for this article.