While many concepts appear similarly in most of the famous programming langauges, it seems metaprogramming is one of those things in which langauges differ greatly.

There's Lisp and CPP of course. In languages that compile to machine code there are templates (C++), macros (C++), different macros (Rust), derive (Rust) and probably more. In dynamic languages there's powerful reflection of various kinds. VM languages might combine both (Java's has reflection, but also annotations which are a special kind of code generation).

It seems this is nowhere near a solved problem.

My question: is there any overview of what's out there and what the strengths and weaknesses are of each? Personal experiences with some of the options are also welcome.

(I'd be particularly interested in compile time meta-programming. Ideally it'd maintain type safety. A separate meta language would be okay, perhaps a non-Turing-complete one that's guaranteed to terminate?).

Write your answer…

Be the first one to answer this question

The Author Card

Mark's photo








Jan 28, 2018