skip to main content
article

Design and implementation of generics for the .NET Common language runtime

Published: 01 May 2001 Publication History

Abstract

The Microsoft.NET Common Language Runtime provides a shared type system, intermediate language and dynamic execution environment for the implementation and inter-operation of multiple source languages. In this paper we extend it with direct support for parametric polymorphism (also known as generics), describing the design through examples written in an extended version of the C# programming language, and explaining aspects of implementation by reference to a prototype extension to the runtime.
Our design is very expressive, supporting parameterized types, polymorphic static, instance and virtual methods, “F-bounded” type parameters, instantiation at pointer and value types, polymorphic recursion, and exact run-time types. The implementation takes advantage of the dynamic nature of the runtime, performing just-in-time type specialization, representation-based code sharing and novel techniques for efficient creation and use of run-time types.
Early performance results are encouraging and suggest that programmers will not need to pay an overhead for using generics, achieving performance almost matching hand-specialized code.

References

[1]
The .NET Common Language Runtime. See website at http://msdn.microsoft.com/net/.
[2]
O. Agesen, S. Freund, and J. C. Mitchell. Adding parameterized types to Java. In Object-Oriented Programming: Systems, Languages, Applications (OOPSLA), pages 215-230. ACM, 1997.
[3]
P. N. Benton, A. J. Kennedy, and G. Russell. Compiling Standard ML to Java bytecodes. In 3rd ACM SIGPLAN International Conference on Functional Programming, September 1998.
[4]
Gilad Bracha, Martin Odersky, David Stoutamire, and Philip Wadler. Making the future safe for the past: Adding genericity to the Java programming language. In Object-Oriented Programming: Systems, Languages, Applications (OOPSLA). ACM, October 1998.
[5]
Peter S. Canning, William R. Cook, Walter L. Hill, John C. Mitchell, and William Olthoff. F-bounded quantification for object-oriented programming. In Conference on Functional Programming Languages and Computer Architecture, 1989.
[6]
R. Cartwright and G. L. Steele. Compatible genericity with run-time types for the Java programming language. In Object-Oriented Programming: Systems, Languages, Applications (OOPSLA), Vancouver, October 1998. ACM.
[7]
R. C. H. Connor. Types and Polymorphism in Persistent Programming Systems. PhD thesis, University of St. Andrews, 1990.
[8]
A. Gordon and D. Syme. Typing a multi-language intermediate code. In 27th Annual ACM Symposium on Principles of Programming Languages, January 2001.
[9]
R. Harper and G. Morrisett. Compiling polymorphism using intensional type analysis. In 22nd Annual ACM Symposium on Principles of Programming Languages, January 1995.
[10]
X. Leroy. Unboxed objects and polymorphic typing. In 19th Annual ACM Symposium on Principles of Programming Languages, pages 177-188, 1992.
[11]
T. Lindholm and F. Yellin. The Java Virtual Machine Specification. Addison-Wesley, second edition, 1999.
[12]
Y. Minamide. Full lifting of type parameters. Technical report, RIMS, Kyoto University, 1997.
[13]
A. Myers, J. Bank, and B. Liskov. Parameterized types for Java. In 24th Annual ACM Symposium on Principles of Programming Languages, pages 132-145, January 1997.
[14]
M. Odersky, P. Wadler, G. Bracha, and D. Stoutamire. Pizza into Java: Translating theory into practice. In ACM Symposium on Principles of Programming Languages, pages 146-159. ACM, 1997.
[15]
Martin Odersky, Enno Runne, and Philip Wadler. Two Ways to Bake Your Pizza - Translating Parameterised Types into Java. Technical Report CIS-97-016, University of South Australia, 1997.
[16]
M. Viroli and A. Natali. Parametric polymorphism in Java: an approach to translation based on reflective features. In Conference on Object-Oriented Programming, Systems, Languages and Applications (OOPSLA). ACM, October 2000.
[17]
M. Viroli and A. Natali. Parametric polymorphism in Java through the homogeneous translation LM: Gathering type descriptors at loadtime. Technical Report DEIS-LIA-00-001, Universit~ degli Studi di Bologna, April 2000.

Cited By

View all

Index Terms

  1. Design and implementation of generics for the .NET Common language runtime

      Recommendations

      Comments

      Information & Contributors

      Information

      Published In

      cover image ACM SIGPLAN Notices
      ACM SIGPLAN Notices  Volume 36, Issue 5
      May 2001
      330 pages
      ISSN:0362-1340
      EISSN:1558-1160
      DOI:10.1145/381694
      Issue’s Table of Contents
      • cover image ACM Conferences
        PLDI '01: Proceedings of the ACM SIGPLAN 2001 conference on Programming language design and implementation
        June 2001
        331 pages
        ISBN:1581134142
        DOI:10.1145/378795
      Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

      Publisher

      Association for Computing Machinery

      New York, NY, United States

      Publication History

      Published: 01 May 2001
      Published in SIGPLAN Volume 36, Issue 5

      Check for updates

      Qualifiers

      • Article

      Contributors

      Other Metrics

      Bibliometrics & Citations

      Bibliometrics

      Article Metrics

      • Downloads (Last 12 months)30
      • Downloads (Last 6 weeks)1
      Reflects downloads up to 03 Jan 2025

      Other Metrics

      Citations

      Cited By

      View all

      View Options

      Login options

      View options

      PDF

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader

      Media

      Figures

      Other

      Tables

      Share

      Share

      Share this Publication link

      Share on social media