1. 5

  2. 5

    Curiously enough I did something remarkably similar to this using perl and xml to generate C++ way back in the day when C++ templates were simply not powerful enough to do the job.

    Alas, Stepanov cheated. When the C++ compiler wasn’t good enough he walked down the corridor and moaned at Stroustup. So Stepanov and STL is famous and I am not. Sigh. ;-)

    Pro’s of this approach:

    • It’s much better than C++ templates or even D’s mixins in that if you do it right, you get well written, clear, well formatted and properly documented vanilla template free C++ code to inspect and debug. (Even the comments get instantiated correctly!)
    • If you do it Right, you have a sane, normalized, DRY, data model of what you are doing that CJ Date would praise. (LifeProTip: Even if you don’t think you have a data model, you probably do, but since you haven’t expended a brain cycle on the subject, it’s not that you don’t have one, it’s that you have a Very Very Bad one.)


    • You get Zero help from the compiler, you can’t ask the compiler what it knows, since you’re operating at a completely different level. D’s trait system is amazingly strong.
    • You have yet another, poorly documented, buggy, badly designed and poorly implemented language, one of thousands and no debugger. In hindsight you realize adding appropriate helper classes to a good existing language such as D or Ruby is much much better.
    • The more decades I’m around XML, the more I hate it. You know how much CJ Date hates how SQL is fundamentally, at the mathematical level, broken? Well XML and XPath is like a very very broken SQL. Oh gawd, just make the pain stop.
    1. 4

      This to me just reads like someone who figured out all the power of using Lisp for code generation… and then stuck with xml & a weird custom template language. I’m trying to read more of the code/examples to get a feel for what makes it so compelling to it’s authors.

      1. 5

        Certainly if you stuck, for whatever reason, using something like C, you can get involved in righting immense amounts of tedious error-prone boiler plate for serialization tasks and the like.

        Then doing something like this can seem immensely liberating.

        But once you got over the wild feeling of joy for saving yourself maintaining thousands of lines of C… and start looking hard at what you are doing… you start to look at it a little differently.

        Yes, the information you are using to drive the generator is data and has a data model and for maintainability needs to be normalised and DRY.

        Yes the template language is a programming language. Is it a Good One?

    2. 4

      From Pieter Hintjens et al at iMatix developed & deployed since the 90’s. Mainly let you develop apps in high-level way that gets turned to high-performance, C code. Only thing I didn’t like was the XML. Here’s some links about it.

      Their philosophy of Model-Oriented Programming:


      Servers from state machines:


      SMT kernel for high-performance multithreading:


      Their web server (original):


      Main site with slide show of their work: