4 ms·
> if something can be calculated at compile time, it should be Often you don't actually want some things done at compile time although they could be done. It c
by staunton 2y ago
> if something can be calculated at compile time, it should be
Often you don't actually want some things done at compile time although they could be done. It can lead to, e.g., excessive executable sizes, excessive compile times. If you've ever considered using `-ftemplate-depth` in C++, you've probably encountered such a case.
Maybe it sounds like I'm splitting hairs and you would say "of course in such crazy cases it's not true", but if you look at C++ projects and what can be done at compile time with modern C++, you would find it's not rare at all.
- tomjakubowski 2y agoYes. My attitude earlier in my life as a programmer was that moving as much as possible to "compile time" was a universal good. The truth is of course, like everything, there are trade offs. I once worked on an Elixir application whose configuration was accessed almost exclusively at compile time. This was done with the well-intended notion that saving runtime cycles was a good thing. It meant that changing any config (e.g.: "name of s3 bucket") meant recompiling the entire application. It also meant we had to wait for a full application rebuild in CI to deploy fixes for simple configuration errors. Not so super.