Does Nim have a published compilation speed (in lines per second) or benchmark that it publishes for comparison with other compilers?
I realize I would need to add that time to the C compilation and link time.
I have an AI program that is currently 35,000 lines that I expect to grow a lot larger.
In my current language an optimized compile/link takes about 4 minutes which cut down on my develop/test cycle time by about two hours per day.
I think if I ported to Nim I would not need an optimized C compile during development because C would be so much faster but I have no idea how longer compiling 35,000 line of Nim would take.
So is there an know benchmarks I could base my estimate on?
I have already found that for best compilation speeds I need to make sure that I am not compiling for debug mode by using the following command line.
nim compile -d:release --opt:speed --out:main-nim main.nim.
"≈1.2 million lines of code per second per CPU core"
(I heard it is now very popular to post claims about programming language without any proof and backing :P :D)
P.S. If anybody tries to disapprove these numbers, I'll just edit the post and add "WIP" there. Problem solved.
(Hopefully, people will get the reference)
Wow 4 minutes to compile 35,000? That is so slow. My project:
Hint: operation successful (145834 lines compiled; 3.777 sec total; 215.672MiB peakmem; Debug Build) [SuccessX]
Yours: 145.8 lines of code per second Nim: 38611 lines of code per second
This includes C compiler and linker time.
You have a really really slow compiler or used too many C++ templates. Nim should take a second to compile your entire project.
Yes, the language I am using is called Red. It is also at least a year or two from a 1.0 release,
It's more of a dynamic language that allow me to execute data as code.
I suppose I could do that in Nim by using the Lua interpreter or just use Lua instead.
Was there a reason you chose Nim over Lua?
According to CLOC (Count Line of Code), Arraymancer is about 14k lines of code (and a lot more generated by macros when you slice a tensor for example) and it takes 224s to compile and run the whole test suite on Travis which includes running complex neural networks.
In my experience compilation of a subset of Arraymancer takes from less than a second to 4 second at most. The bottleneck might be the console printing speed.
Something I don't really see people addressing is modularity. I don't know how you've organized your code, but Nim compiles modular code in modular fashion; that is, piece-by-piece, so that if you change one file, you don't have to wait for loads of other things to (re-)compile. If your code is well organized, you won't have to compile 35,000 lines every time you change one thing.
C and C++ are not really modular, at least not as commonly used. They have the disadvantage that #include forces lots of stuff to (re-)compile that shouldn't have to, even when you have a well-prepared Makefile. One proposal for C++20 is to introduce modularity to the language.
I don't know how Red works, so perhaps that's not the root of your difficulty, but I figured it was worth throwing out there.
"Was there a reason you chose Nim over Lua?"
Well I don't know Lua, but I am tried for other dynamic languages. Python, JavaScript - they are all super slow. They don't catch typos. They contribute to the major problem in the software industry where we keep piling up layer and layer of abstractions on top of hardware, os, GUI, HTML. We use more and more libraries without knowing what they do. More and more for no reason!
I want speed and I don't want typos. I don't want to get stuck in the "software layers".
There is no such thing as "compilation speed". There are lots of different CPUs in existence: some specialized for mobile, some for home desktops, and some for multi-million-dollar super-computer compilers in the cloud.
So it's about time we start measuring compilation in terms of cost (given free market competition between different cloud service providers) rather than time.
(There's also overhead time to sync your source code into RAM of the compiler in the cloud and return the result, but on the modern Internet that's less than 0.1 seconds.)