On 6/19/15 11:45 PM, charleyb123 . wrote:
However, even though you may be content with the ease of writing TMP code in C++14, I think you might be surprised to see how shorter it could be if you used Hana. This is, for example, the case of Zach's Units-BLAS library. It was really quite short with C++14 only, but it was even shorter with Hana. And the code was written with a higher level of abstraction. And in that case, there was even a compile-time speedup over std::tuple + handwritten stuff.
"really quite short" is good enough if the cost is having to depend on a "32k header mega library" as David notes. Not to mention having to learn another library for me and for all future maintainers.
Louis Dionne respondeth:
Regarding the "32k header mega library" thing, I'd like to precise that it's not as bad as it seems. First, part of it is just documentation. Second, that's a _real_ 32 kLOC, not a 100 kLOC of dependencies hidden behind a 5 kLOC library. Hana as no dependencies except the
, <utility> and <cstddef> headers, which you probably already use anyway. In comparison, including almost any other Boost library will pull in a lot more than 32 kLOCs in dependencies. This.
For TMP libraries, and particularly for their application in large production codebases, I conclude the following pattern tends to hold: MORE IS LESS.
Paraphrased, this would be, "More reusable code in libraries means less application-specific code is necessary, so the program is more feature-rich and functionality evolves better over time."
Explanation: A "richer" (well-defined/implemented) library tends to provide non-linear value improvements over a "smaller" library.
In large codebases, a "more-complete" library is superior because:
[snip] Well, that sums it up. So let us just agree to disagree. I'll state my opinion again: less is more in post C++11 TMP. 98% of TMP can be done in a simple single header file as was done by Peter Dimov and Eric Niebler with a very simple, straightforward interface. 98% is more than enough for me. I've written heavy TMP most of my life as a C++ programmer and the weight of the code was because of the limitations of C++03 (and prior!). Let me just make this clear: I am for Hanna's acceptance into boost. It is cool and well implemented. Many people will find a use for it. It's just not for me. Regards, -- Joel de Guzman http://www.ciere.com http://boost-spirit.com http://www.cycfi.com/