Comment by joiguru

5 years ago

Honest question. Why not just use C/subset of C++ with a template language like Python+Jinja2 for meta programming?

Code generation is already popular with popular C++ libraries like protobuf and in game dev.

When you use a template language, how do you JIT the code so you can run it in the same process?

How do you parse C/C++ header files so you can introspect their types or functions and take actions based on the results?

How do you write clean abstractions for code generation? Do you build your own C++ AST abstraction entirely from scratch? If not what do you use, and how much power does it expose (and what tradeoffs come with the level of power that you get)?

Terra lets you do all of these things in a clean way with well-defined, predictable semantics that don't leave you scratching your head when you get to 4 nested levels of macros and complex dynamic behavior that depends on program inputs.