Jonathan Blow has created a programming language called Jai and has said that it is faster to emit C code and run it through MSVC than to emit LLVM IR and run it through LLVM for debug builds. And he spent a lot of time optimizing and tweaking it.
AFAIK the C backend for Jai is a thing of the past - the two backends you hear about now are the LLVM one, and his own x64 instruction generation. With his x64 one, I think he is aiming to compile 1 million lines of code per second eventually. It's nuts that a relatively small team can pull this off, but that the huge scale of effort that goes into the likes of Clang and other similar compilers can come nowhere near this level of performance.
Yes, but my point is this - when you consider the decisions made by the people designing C++, and the effort going compilers like Clang - both must be severely misguided before a very small team like Thekla can produce a very serious competition that is many orders of magnitude faster. Yes, C++ is more complicated, but only because it was designed that way. Jonathan Blow cares about the time developers waste waiting on compilation, trying to understand bad error messages, etc., and keeps the "joy of programming" as a very high priority. I honestly think C++ will start to fade away to be another language of the past like Fortran or COBOL once Jai is (eventually) released.
clang and GCC were able to compile about 200k lines per second (after preprocessing)
I'm skeptical regarding that figure - do you have any links you can point me to? I know this is really old, but here Jonathan Blow discusses progress of speed in his language at a time when it was not at its best. He specifically talks about 1m loc/sec at 25:21.
Also, as far as I know, Jai's backend has very rudimentary optimizations.
Jai has two backends - an LLVM one to take advantage of optimisations for release builds, and his own x64 backend for development. The x64 backend is more rudimentary, but that's sort of the point - it's designed for fast turnaround. Some limited optimisation has been spoken about for this, but it will never be as optimised as the LLVM backend, because that's not its purpose.
Preprocessed file is 773 kB in size, with 22k lines of code:
$ tokei preprocessed.cpp
------------------------------------------------------------------------------
Language Files Lines Code Comments Blanks
-------------------------------------------------------------------------------
C++ 1 31761 22020 0 9741
-------------------------------------------------------------------------------
Total 1 31761 22020 0 9741
-------------------------------------------------------------------------------
Compilation of this file takes 0.3 s
Benchmark #1: g++ -c -std=c++17 -O3 preprocessed.cpp
Time (mean ± σ): 305.1 ms ± 7.3 ms [User: 281.8 ms, System: 23.4 ms]
Range (min … max): 295.8 ms … 315.6 ms 10 runs
Which means GCC can compile 73 kloc/s. Lower than 200 kloc/s I mentioned before, but still not "many orders slower". Clang compiles the same code in ~270 ms.
I also tested on more realistic code. I took the file ninja.cc from Ninja build system. Preprocessed file is 1.7 MB in size and has 45.7 kloc. It takes 830 ms to compile, which gives ~ 55 kloc/s.
4
u/czipperz May 10 '20
Jonathan Blow has created a programming language called Jai and has said that it is faster to emit C code and run it through MSVC than to emit LLVM IR and run it through LLVM for debug builds. And he spent a lot of time optimizing and tweaking it.