Macros are for when you run out of language

Updated September 27, 2021

As @littlecalculist always told me, “macros are for when you run out of language”. If you still have language left—and Rust gives you a lot of language—use the language first.

@pcwalton

The benefit of a macro or DSL is that you can model all of the relevant state of the system, and use it to compile a solution.

When APIs have a lot of interconnected state, this might be the only reasonable approach.

Examples

  • Elm
  • GLSL shader compilers