Online / 5 & 6 February 2022

visit

C meta-programming for the masses with C%: cmod


C% (from "C with mods") is an experimental meta-programming language that aims to make coding in C more efficient and fun!

Together with cmod, the reference pre-processor/code generator (written using C% itself), this project enables the C programmer with generic meta-programming constructs such as: parameterized verbatim code snippets, mapping code to static data tables (in TSV or JSON format), multi-pass code evaluation (allowing meta-meta-programming), compile-time command execution (allowing code generation from any other software/language), etc. as well as C-specific constructs such as: function types, named parameters, selection over strings and structs, etc. The C% standard library provides additional functionality through convenience snippets.

Some of the things that C% aims to make achievable are:

  • Reusability: Avoid code duplication through parameterized verbatim code snippets.
  • Consistency: Use the same data at different locations and across compilation units by mapping static data tables.
  • Efficiency: Achieve common functionality through C idioms standardized in keywords and the C% standard library.
  • Concision: Write and work with concise code and leave the gory details to the generated code.
  • Expressivity: Better express the intent of code by avoiding boilerplate noise.
  • Transparency: Inspect all the generated code and have it checked by the compiler.
  • Abstraction: Identify similar things in your code and handle them in a uniform manner.
  • Extensibility: Once uniform handling is in place, adding an additional element becomes easier.

Beyond C meta-programming, C%'s generic keywords enable meta-programming in other languages such as Python, Flex/Bison, etc.

For full documentation, please refer to the README.

Speakers

Photo of Sirio Bolaños Puchet Sirio Bolaños Puchet

Links