Using Functional Languages to Facilitate C++ Metaprogramming

Haeri, Seyed Hossein;Schupp, Sibylle;Hüser, Jonathan
(2012) the 8th ACM SIGPLAN Workshop on Generic Programming — Location: Copenhagen, Denmark (12.September.2012)

Files

UsingFunctionalLanguagesToFacilitateCMetaprogramming.pdf
  • Open Access
  • Adobe PDF
  • 626.12 KB

Details

Authors
  • Haeri, Seyed HosseinUCLouvain
    Author
  • Schupp, SibylleHamburg University of Technology
    Author
  • Hüser, JonathanHamburg University of Technology
    Author
Abstract
Template and Preprocessor Metaprogramming are both well-known in the C++ community to have much in common with Functional Programming (FP). Recently, very few research threads on underpinning these commonalities have emerged to empower cross-development of C++ Metaprogramming (C++MP) and FP. In this paper, we program a self-contained real-world example in a side-by-side fashion to explore the usefulness of a few mainstream FP languages for this purpose: We develop a compile-time abstract datatype for Rational Numbers in C++. We then present the runtime equivalent in HASKELL, F#, and Scala to discuss some FP parallels across the languages. Here, we consider semi-automatic translation between C++MP and FP languages, for earlier studies on these parallels have already obviated the impracticability of fully automatic translations. Our study also shows the superiority of multiparadigm FP languages over single-paradigm ones. In particular, we conclude Scala to currently be the most promising FP language for facilitating C++MP.
Affiliations

Citations

Haeri, S. H., Schupp, S., & Hüser, J. (2012). Using Functional Languages to Facilitate C++ Metaprogramming. Proceedings of the 8th ACM SIGPLAN workshop on Generic programming - WGP ’12. Published. the 8th ACM SIGPLAN Workshop on Generic Programming, Copenhagen, Denmark. https://doi.org/10.1145/2364394.2364400