3 ms·
I'm a full-time C++ programmer, and I keep up with the language pretty well, but I absolutely hate template meta-programming. We use it in parts of our codebas
by jlarocco 12y ago
I'm a full-time C++ programmer, and I keep up with the language pretty well, but I absolutely hate template meta-programming. We use it in parts of our codebase at work and I always dread when I have to interact with those parts of the code.
It's horribly ugly and verbose compared to other languages, like Lisp, that basically solve the same problem of computation at compile time. Even this library that supposedly cleans things up is pretty ugly as far as I'm concerned.
It's incredibly slow to compile. Somebody posted "Conway's Game of Life in TMP" the other day, and one of the template parameters was the number of frames to generate at compile time. I changed it from 3 to 10 and kicked off a compilation, and it ran for over 12 hours, used 10+ Gb of RAM, and still hadn't finished when I killed it the next day. I can do the same thing in Lisp, also at compile time, and it'll be a fraction of the code, easier to read, the same syntax as usual Lisp, and execute in negligible time for 10 frames.
And don't get me started on the error messages. Clang is pretty good, but it's still not good enough.
And the worst part of TMP is that due to the other problems with it, it's considered "black magic" by many people and so they don't bother learning it.
Until some of the problems are fixed, I don't think TMP will ever take off and become popular. It's just too hard to work with.
I guess I'm biased by writing a lot of Lisp in my free time lately. Lisp solved the same problem TMP is trying to solve, infinitely better, 50 years ago.
- santaclaus 12y ago> Until some of the problems are fixed, I don't think TMP will ever take off and become popular. It's just too hard to work with. Perhaps, although I've seen expression templates a few times in the wild.