Re:C++ vs. Rust Build Times
by pharmakom on Friday January 06, 2023 @05:24AM
(#34273090)
I think it’s acceptable for Rust compilation to end up slower than C++. After all, the compiler does a lot more work for you with the borrow checker and all. That doesn’t mean we shouldn’t strive to make it better though.
[ Parent
| on HN ]
I'd wager that the C++ compiler does more work churning through #include-s than the Rust compiler does tracking borrows.
C++20 modules is supposed to fix that. I wish I could get compilers that implemented them.
There you go, https://visualstudio.microsoft.com/vs/community/
One example to get you started, https://github.com/pjmlp/RaytracingWeekend-CPP
I target linux with my C++.
That wasn't part of the comment.
What makes you think it is slower because of the borrow checker?
It’s not because of the borrow checker specifically, but the type system design that makes the borrow checker possible is a big part of what leads to slower compilation times.
On the other hand, that extra time is traded off against not having to deal with bugs at runtime that the type system is able to catch. Rust is one of the better languages when it comes to making illegal states unrepresentable.
I know the article is really detailed, and I don’t remember a lot of it either!
But he does specifically break down how much of compilation time is spent in the borrow checker, LLVM, macro expansion, etc.