skip to main content
10.1145/1596614.1596619acmconferencesArticle/Chapter ViewAbstractPublication PagesicfpConference Proceedingsconference-collections
research-article

The function concept in C++: an empirical study

Published: 30 August 2009 Publication History

Abstract

Higher-order functions are essential for generic programming. While they are naturally supported in functional programming languages, there are no higher-order functions in C++. There, various function datatypes exist that simulate the effect of higher-order programming in different ways - as classes designed in the imperative, object-oriented, or meta-programming spirit. With the recent addition of concepts, another alternative for supporting parameterization by functions has yet become available. No guidelines exist, however, whether, or when, to prefer a concept for functions over any of the existing function datatypes; nor have the function datatypes themselves been compared. We provide an empirical study that assesses performance, expressivity, and convenience. The study shows that the function concept mechanism is faster and at least as expressive as the best function datatype, but, due to the principal difference between concept- and type-based approaches, also less convenient to use.

References

[1]
Boost C++ Libraries, 2007. URL http://www.boost.org/. last checked: May 1. 2009.
[2]
Working draft, standard for programming language C++. Technical Report N2857=09-0047, ISO/IEC JTC1/SC22/WG21 - C++, 2009.
[3]
FAC++T: Multiparadigm Programming with C++., 2001. URL http://www.fz-juelich.de/jsc/FACT/start/index.html. last checked: May 1. 2009.
[4]
GCC, the GNU Compiler Collection, 2009. URL http://gcc.gnu.org/. last checked: May 1. 2009.
[5]
D. Abrahams and A. Gurtovoy. C++ Template Metaprogramming. Concepts, Tools, and Techniques from Boost and Beyond. C++ In-Depth Series. Addison-Wesley Longman, Amsterdam, 2005.
[6]
J. Bernardy, P. Jansson, M. Zalewski, S. Schupp, and A. Priesnitz. A comparison of C++ concepts and Haskell type classes. In WGP '08: Proceedings of the ACM SIGPLAN workshop on Generic programming, pages 37--48, New York, NY, USA, 2008. ACM.
[7]
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. ACMPress, 2003.
[8]
R. Garcia, J. Järvi, A. Lumsdaine, J. Siek, and J. Willcock. An Extended Comparative Study of Language Support for Generic Programming. Journal of Functional Programming, 17:145--205, 2007.
[9]
D. Gregor, J. Järvi, J. Siek, B. Stroustrup, G. Dos Reis, and A. Lumsdaine. Concepts: Linguistic Support for Generic Programming in C++. In Proceedings of the 2006 OOPSLA Conference, volume 41, 2006.
[10]
D. Gregor, J. Järvi, J. Maurer, and J. Merrill. Proposed Wording for Variadic Templates. Technical Report N2080=06-0150, ISO/IEC JTC1/SC22/WG21 - Programming Language C++, Core Working Group, 2007.
[11]
D. Gregor, B. Stroustrup, J. Widman, and J. Siek. Proposed Wording for Concepts (Revision 8). Technical Report N2741=08-0251, ISO/IEC JTC1/SC22/WG21 - Programming Language C++, CoreWorking Group, 2008.
[12]
J. Järvi, G. Powell, and A. Lumsdaine. The lambda library: unnamed functions in C++. Software - Practise and Experience, 33, 2003.
[13]
M. P. Jones. A system of constructor classes: overloading and implicit higher-order polymorphism. In FPCA '93: Conference on Functional Programming and Computer Architecture, Copenhagen, Denmark, pages 52--61, New York, N.Y., 1993. ACM Press.
[14]
K. Läufer. A Framework for Higher-order Functions in C++. In COOTS'95: Proceedings of the USENIX Conference on Object-Oriented Technologies (COOTS), pages 103--116, Berkeley, CA, USA, 1995. USENIX Association.
[15]
D. Lincke, P. Jansson, M. Zalewski, and C. Ionescu. Generic Libraries in C++ with Concepts from High-Level Domain Descriptions in Haskell. A Domain-Specific Library for Computational Vulnerability Assessment. In Proceedings of the IFIP Working Conference on Domain Specific Languages, 2009. To appear.
[16]
B.McNamara and Y. Smaragdakis. Functional programming with the FC++ library. Journal of Functional Programming, 14(4):429--472, 2004.
[17]
B. Stroustrup. The Design and Evolution of C++. Addison-Wesley, 1994.
[18]
D. Vandervoorde and N.M. Josuttis. C++ Templates: The Complete Guide. Addison-Wesley, Amsterdam, 2002.
[19]
M. Zalewski. Generic Programming with Concepts. PhD thesis, Chalmers University of Technology, Gothenburg, 2008.
[20]
M. Zalewski, A. Priesnitz, C. Ionescu, N. Botta, and S. Schupp. Multi-Language Library Development. From Haskell Type Classes to C++ Concepts. In Multiparadigm Programming with Object-Oriented Languages, an ECOOP workshop, 2007.

Recommendations

Comments

Information & Contributors

Information

Published In

cover image ACM Conferences
WGP '09: Proceedings of the 2009 ACM SIGPLAN workshop on Generic programming
August 2009
100 pages
ISBN:9781605585109
DOI:10.1145/1596614
  • Program Chairs:
  • Patrik Jansson,
  • Sibylle Schupp
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]

Sponsors

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 30 August 2009

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. C++
  2. concepts
  3. higher-order functions

Qualifiers

  • Research-article

Conference

ICFP '09
Sponsor:

Acceptance Rates

Overall Acceptance Rate 30 of 43 submissions, 70%

Upcoming Conference

ICFP '25
ACM SIGPLAN International Conference on Functional Programming
October 12 - 18, 2025
Singapore , Singapore

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • 0
    Total Citations
  • 494
    Total Downloads
  • Downloads (Last 12 months)3
  • Downloads (Last 6 weeks)0
Reflects downloads up to 22 Feb 2025

Other Metrics

Citations

View Options

Login options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Figures

Tables

Media

Share

Share

Share this Publication link

Share on social media