3 ms·
The "performance" you get by using templates is offset by binary size and/or compilation time. You can't get something for nothing.
by dvt 10y ago
The "performance" you get by using templates is offset by binary size and/or compilation time. You can't get something for nothing.
- digikata 10y agoAgreed, and then for example when you go to further reexamine performance and maybe try to fit parts of the binaries into cache, then you're trying to possibly optimize at two-different levels at the same time. This isn't to say that Rust will have the same problem, I hope it avoids it entirely. But if the question is why is there a vague feeling of dread when Rust declares a turing complete type system - a C++ template meta-programming ghost is the reason for me.
- kibwen 10y agoAs tatterdemalion's top comment in this thread states, the deliberate restrictions imposed by the Rust compiler prevent type-level programming from being used for the arcane tasks that TMPL achieves in C++. To say nothing of the fact that Rust has far easier and better ways of achieving metaprogramming than abusing the type system...
- pjmlp 10y agoCompilation time is a consequence of lack of modules. In C++11 you can pre-instantiate common used templates (extern template)and hopefully C++20 will finally get modules. Until then, those that are able to use just VS C++ 2015 and 2017, can make use of incremental linking and experimental modules, to ease the pain a bit.