A trick to improve build times in **C++** is to concatenate the source files. 
(Or equivalently, `#include` all files into a single compilation unit, which 
maintains source line numbers for debugging.) Precompiled headers provide 
almost no speed-up at all for templates, in my experience.

In **Nim**, if you use a specific generic proc, then that proc will be 
specialized in the `nimcache/module.c` file for the module in which that proc 
is defined. (You can verify that yourself. I just did. That's one of the great 
benefits of transpiling to **C**.) No matter how many instances or uses across 
all the modules imported by your executable, there will be just one 
specialization per type(s). So it will have the same advantage as 
concatenation. And of course, since that file is **C**, not **C++**, it will 
compile even faster and consume much less memory.

So the answer is yes, **Nim** generics compilation scales well.

Reply via email to