Re:Show HN: Compile-time HTML parsing in C++14
by rep_movsd on Tuesday August 01, 2017 @02:26AM
(#14898340)
It's coming soon, as always.
A lot of the STL is already being constexpr-ized (as Stephen T Lavalej has mentioned)
This code i wrote takes about 5 seconds on gcc and 1.5 seconds on clang to compile for a 1000 node HTML template (about 28 KB). Definitely slow, but not really really slow.
I have a feeling recursion slows down the compile time, I will attempt an iteration based version eventually and see.
The work shown here is impressive, but the point is that it should not be. D has shown that variable initialization at compile time can be painless.
The main limitations I find are: a) Lack of support in the standard library (e.g., you should code your own sort, vector class, etc.)
b) Terrible Terrible Terrible compilation times.
c) Lack of a dynamic memory allocation within constexpr.
constexpr functions are not evaluated while parsing (e.g., the code is not compiled and then executed). My use case, which was to avoid a 1 second preprocessing time while loading a library, took more than 20 minutes to compile and used more than 60 GB of RAM (on GCC7, CLANG did not even manage to compile).
Stuff like initializing a bitset can easily eat all your ram (e.g. this fails to compile): #include <bitset> int main() { std::bitset<102410241024> bs; } https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63728