Essential language support for generic programming
2005, ACM SIGPLAN Notices
https://doi.org/10.1145/1064978.1065021Abstract
Concepts are an essential language feature for generic programming in the large. Concepts allow for succinct expression of constraints on type parameters of generic algorithms, enable systematic organization of problem domain abstractions, and make generic algorithms easier to use. In this paper we present the design of a type system and semantics for concepts that is suitable for non-type-inferencing languages. Our design shares much in common with the type classes of Haskell, though our primary influence is from best practices in the C++ community, where concepts are used to document type requirements for templates in generic libraries. Concepts include a novel combination of associated types and same-type constraints that do not appear in type classes, but that are similar to nested types and type sharing in ML.
FAQs
AI
What distinguishes concepts from traditional type classes in programming languages?
The paper finds concepts allow multiple models with the same member name, unlike type classes, enhancing modularity. This distinction is crucial for languages without Haskell's type inference.
How does F G improve language support for generic programming?
In F G, concepts and models provide first-class support for expressing admissible type sets. This captures the essence of generic programming better than subtype bounds or type classes.
What limitations exist in current programming languages supporting generic programming?
The evaluation revealed current languages inadequately represent essential generic programming features like concepts, leading to issues with modularity and encapsulation. For example, associated types often introduce cumbersome clutter in interface definitions.
What methodology did the authors use to evaluate existing language features?
The study implemented a generic graph library in four different programming paradigms, assessing their support for generic programming. This hands-on evaluation highlighted strengths and weaknesses in each approach.
What are the potential future improvements discussed for F G?
The authors mention enhancements such as nested requirements, implicit instantiation rules, and static overload resolution to alleviate the clutter in model member access. Additionally, future work will address algorithm specialization and function overloading.
References (66)
- Ada 95 Reference Manual, 1997.
- J.-D. Boissonnat, F. Cazals, F. Da, O. Devillers, S. Pion, F. Rebufat, M. Teillaud, and M. Yvinec. Programming with CGAL: the example of triangulations. In Proceedings of the fifteenth annual symposium on Computational geometry, pages 421-422. ACM Press, 1999.
- Boost. Boost C++ Libraries. http://www.boost.org/.
- G. Bracha, N. Cohen, C. Kemper, S. Marx, et al. JSR 14: Add Generic Types to the Java Programming Language, April 2001. http://www.jcp.org/en/jsr/detail?id=014.
- K. B. Bruce, A. Schuett, and R. van Gent. PolyTOIL: A type- safe polymorphic object-oriented language. In W. Olthoff, editor, Proceedings of ECOOP '95, number 952 in Lecture Notes in Computer Science, pages 27-51. Springer-Verlag, 1995.
- P. Canning, W. Cook, W. Hill, W. Olthoff, and J. C. Mitchell. F-bounded polymorphism for object-oriented programming. In Proceedings of the fourth international conference on functional programming languages and computer architecture, 1989.
- L. Cardelli and P. Wegner. On understanding types, data abstraction, and polymorphism. ACM Computing Surveys, 17(4):471-522, 1985.
- M. Chakravarty, G. Keller, S. P. Jones, and S. Marlow. Associated types with class. In Proceedings of the 32nd ACM-SIGACT Symposium on Principles of Programming Languages, POPL 2005, Long Beach, California, pages 1-13. ACM, Jan. 2005.
- K. Chen, P. Hudak, and M. Odersky. Parametric type classes. In LISP and Functional Programming, pages 170-181, 1992.
- G. J. Ditchfield. Contextual polymorphism, 1994.
- G. J. Ditchfield. Cforall reference manual and rationale, 1997.
- E. Ernst. gbeta -a Language with Virtual Attributes, Block Structure, and Propagating, Dynamic Inheritance. PhD thesis, Department of Computer Science, University of Aarhus, Århus, Denmark, 1999.
- E. Ernst. Family polymorphism. In ECOOP, volume 2072 of Lecture Notes in Computer Science, pages 303-326. Springer, June 2001.
- R. Garcia, J. Järvi, A. Lumsdaine, J. Siek, and J. Willcock. A comparative study of language support for generic programming. In Proceedings of the 18th ACM SIGPLAN conference on Object- oriented programing, systems, languages, and applications, pages 115-134. ACM Press, Oct. 2003.
- J.-Y. Girard. Interprtation Fonctionnelle et Élimination des Coupures de l'Arithmtique d'Ordre Suprieur. Thse de doctorat d'tat, Universit Paris VII, Paris, France, 1972.
- J. A. Goguen, T. Winker, J. Meseguer, K. Futatsugi, and J.- P. Jouannaud. Introducing OBJ. In Applications of Algebraic Specification using OBJ. Cambridge University Press, 1992.
- C. V. Hall, K. Hammond, S. L. P. Jones, and P. L. Wadler. Type classes in Haskell. ACM Trans. Program. Lang. Syst., 18(2):109-138, 1996.
- International Standardization Organization (ISO). ANSI/ISO Standard 14882, Programming Language C++. 1 rue de Varembé, Case postale 56, CH-1211 Genève 20, Switzerland, 1998.
- J. Järvi, A. Lumsdaine, J. Siek, and J. Willcock. An analysis of constrained polymorphism for generic programming. In K. Davis and J. Striegnitz, editors, Multiparadigm Programming in Object- Oriented Languages Workshop (MPOOL) at OOPSLA, Anaheim, CA, Oct. 2003.
- J. Järvi, J. Willcock, and A. Lumsdaine. Algorithm specialization and concept constrained genericity. In Concepts: a Linguistic Foundation of Generic Programming. Adobe Systems, Apr. 2004.
- M. P. Jones. Type classes with functional dependencies. In European PLDI'05, 11 2005/4/19
- Symposium on Programming, number 1782 in LNCS, pages 230-244.
- W. Kahl and J. Scheffczyk. Named instances for Haskell type classes. In R. Hinze, editor, Proc. Haskell Workshop 2001, volume 59 of ENTCS, 2001. See also: http://ist.unibw-muenchen.de/ Haskell/NamedInstances/.
- D. Kapur and D. Musser. Tecton: a framework for specifying and verifying generic system components. Technical Report RPI-92-20, Department of Computer Science, Rensselaer Polytechnic Institute, Troy, New York 12180, July 1992.
- D. Kapur, D. R. Musser, and X. Nie. An overview of the tecton proof system. Theoretical Computer Science, 133:307-339, Oct. 1994.
- D. Kapur, D. R. Musser, and A. Stepanov. Operators and algebraic structures. In Proc. of the Conference on Functional Programming Languages and Computer Architecture, Portsmouth, New Hampshire. ACM, 1981.
- D. Katiyar, D. Luckham, and J. Mitchell. A type system for prototyping languages. In Conference Record of POPL '94: 21st ACM SIGPLAN-SIGACT Symposium of Principles of Programming Languages, Portland, Oregon, pages 138-150, 1994.
- A. Kennedy and D. Syme. Design and implementation of generics for the .NET Common Language Runtime. In Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI), pages 1-12, Snowbird, Utah, June 2001.
- A. Kershenbaum, D. Musser, and A. Stepanov. Higher order imperative programming. Technical Report 88-10, Rensselaer Polytechnic Institute, 1988.
- U. Köthe. Handbook on Computer Vision and Applications, volume 3, chapter Reusable Software in Computer Vision. Acadamic Press, 1999.
- D. Le Botlan and D. Rémy. MLF: Raising ML to the power of System- F. In Proceedings of the International Conference on Functional Programming (ICFP 2003), Uppsala, Sweden, pages 27-38. ACM Press, aug 2003.
- X. Leroy, D. Doligez, J. Garrigue, D. Remy, and J. Vouillon. The Object Caml Documentation and User's Manual, September 2003.
- B. Liskov, R. Atkinson, T. Bloom, E. Moss, C. Schaffert, B. Scheifler, and A. Snyder. CLU reference manual. Technical Report LCS-TR- 225, Cambridge, MA, USA, October 1979.
- B. Liskov and J. Guttag. Abstraction and specification in program development. MIT Press, Cambridge, MA, USA, 1986.
- D. MacQueen. An implementation of Standard ML modules. In Proceedings of the 1988 ACM Conference on LISP and Functional Programming, Snowbird, UT, pages 212-223, New NY, 1988. ACM.
- B. Meyer. Eiffel: the Language. Prentice Hall, New York, NY, first edition, 1992.
- Microsoft Corporation. Generics in C#, September 2002. Part of the Gyro distribution of generics for .NET available at http: //research.microsoft.com/projects/clrgen/.
- R. Milner, M. Tofte, and R. Harper. The Definition of Standard ML. MIT Press, 1990.
- J. C. Mitchell. Polymorphic type inference and containment. Information and Computation, 76(2-3):211-249, 1988.
- D. R. Musser and A. Stepanov. Generic programming. In ISSAC: Proceedings of the ACM SIGSAM International Symposium on Symbolic and Algebraic Computation, 1988.
- D. R. Musser and A. A. Stepanov. A library of generic algorithms in Ada. In Using Ada (1987 International Ada Conference), pages 216-225, New York, NY, Dec. 1987. ACM SIGAda.
- G. Nelson and D. C. Oppen. Fast decision procedures based on congruence closure. J. ACM, 27(2):356-364, 1980.
- T. Nipkow. Structured Proofs in Isar/HOL. In H. Geuvers and F. Wiedijk, editors, Types for Proofs and Programs (TYPES 2002), volume 2646, pages 259-278, 2003.
- T. Nipkow, L. C. Paulson, and M. Wenzel. Isabelle/HOL -A Proof Assistant for Higher-Order Logic, volume 2283 of LNCS. Springer, 2002.
- M. Odersky and al. An overview of the scala programming language. Technical Report IC/2004/64, EPFL Lausanne, Switzerland, 2004.
- M. Odersky, V. Cremet, C. Röckl, and M. Zenger. A nominal theory of objects with dependent types. In Proc. ECOOP'03, Springer LNCS, 2003.
- M. Odersky and K. Läufer. Putting type annotations to work. In Proceedings of the 23rd ACM SIGPLAN-SIGACT symposium on Principles of programming languages, pages 54-67. ACM Press, 1996.
- B. C. Pierce. Intersection types and bounded polymorphism. Mathematical Structures in Computer Science, 11, 1996.
- B. C. Pierce. Types and Programming Languages. MIT Press, 2002.
- W. R. Pitt, M. A. Williams, M. Steven, B. Sweeney, A. J. Bleasby, and D. S. Moss. The bioinformatics template library: generic components for biocomputing. Bioinformatics, 17(8):729-737, 2001.
- E. Poll and S. Thompson. The Type System of Aldor. Technical Re- port 11-99, Computing Laboratory, University of Kent at Canterbury, Kent CT2 7NF, UK, July 1999.
- D. Rémy and J. Vouillon. Objective ML: An effective object-oriented extension to ML. Theory And Practice of Object Systems, 4(1):27-50, 1998. A preliminary version appeared in the proceedings of the 24th ACM Conference on Principles of Programming Languages, 1997.
- J. C. Reynolds. Towards a theory of type structure. In B. Robinet, editor, Programming Symposium, volume 19 of Lecture Notes in Computer Science, pages 408-425, Berlin, 1974. Springer-Verlag.
- J. Siek, L.-Q. Lee, and A. Lumsdaine. The generic graph component library. In Proceedings of the 1999 ACM SIGPLAN conference on Object-oriented programming, systems, languages, and applications, pages 399-414. ACM Press, 1999.
- J. Siek, L.-Q. Lee, and A. Lumsdaine. The Boost Graph Library: User Guide and Reference Manual. Addison-Wesley, 2002.
- J. Siek and A. Lumsdaine. Essential language support for generic programming: Formalization part 1. Technical Report 605, Indiana University, December 2004.
- J. G. Siek and A. Lumsdaine. Advances in Software Tools for Scientific Computing, chapter A Modern Framework for Portable High Performance Numerical Linear Algebra. Springer, 2000.
- Silicon Graphics, Inc. SGI Implementation of the Standard Template Library, 2004. http://www.sgi.com/tech/stl/.
- A. Stepanov. gclib. http://www.stepanovpapers.com, 1987.
- A. A. Stepanov and M. Lee. The Standard Template Library. Technical Report X3J16/94-0095, WG21/N0482, ISO Programming Language C++ Project, May 1994.
- B. Stroustrup. Parameterized types for C++. In USENIX C++ Conference, October 1988.
- J. Tiuryn and P. Urzyczyn. The subtyping problem for second-order types is undecidable. Information and Computation, 179(1):1-18, 2002.
- M. Troyer, S. Todo, S. Trebst, and A. F. and. ALPS: Algorithms and Libraries for Physics Simulations. http://alps.comp-phys. org/.
- P. Wadler and S. Blott. How to make ad-hoc polymorphism less ad- hoc. In ACM Symposium on Principles of Programming Languages, pages 60-76. ACM, Jan. 1989.
- J. Walter and M. Koch. uBLAS. Boost. http://www.boost.org/ libs/numeric/ublas/doc/index.htm.
- J. Willcock, J. Järvi, A. Lumsdaine, and D. Musser. A formalization of concepts for generic programming. In Concepts: a Linguistic Foundation of Generic Programming at Adobe Tech Summit. Adobe Systems, Apr. 2004.