3 ms·
A macro processing language is pretty much a language purpose-built for describing how to copy text from here to there while performing certain changes in the p
by alxlaz 8y ago
A macro processing language is pretty much a language purpose-built for describing how to copy text from here to there while performing certain changes in the process.
A templating system is a set of language-specific constructs (a library, a module, whatever they happen to call in that language) that essentially deals only with the latter (i.e. describing how to perform the changes). It's generally up to you to deal with the "copy text from here to there" part, although most templating engines give you a specific interface that you have to adhere to.
I suppose the difference is better illustrated by PyExpander ( http://pyexpander.sourceforge.net/ http://pyexpander.sourceforge.net/ ) which is a macro processing language based on python vs. Jinja (http://jinja.pocoo.org/ http://jinja.pocoo.org/) which is a templating engine for Python.
I don't think any general statement about which on is "better" can be meaningful. I suppose that, if you have a full project already written in one language, with all work performed by a single program, it's easier to get what you need via templating engine. If your project is already a collection of tools, whose outputs you need to tie together, it's often less effort to bring in a macro language than write your processing logic from scratch in a non-macro language just to leverage a templating engine. Assuming, of course, that you have someone who knows the macro language in your team ;-). If all your team knows is Jinja2, you're gonna get Jinja2.
FWIW, I also do a little M4 from time to time (and a long time ago I also worked with GPP) and find both of them fairly easy to use.