Using functional languages to facilitate C++ metaprogramming

  • Authors:
  • Seyed Hossein Haeri;Sibylle Schupp;Jonathan Hüser

  • Affiliations:
  • Hamburg University of Technology, Hamburg, Germany;Hamburg University of Technology, Hamburg, Germany;Hamburg University of Technology, Hamburg, Germany

  • Venue:
  • Proceedings of the 8th ACM SIGPLAN workshop on Generic programming
  • Year:
  • 2012

Quantified Score

Hi-index 0.00

Visualization

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.