News for hackers. Stuff that matters.
Re:Still in love with Rust by EugeneOZ on Thursday November 22, 2018 @03:42AM (#18508721)
Out of curiosity, not to argue: how much time it takes in C++ to compile 45k LoC?
Re:Still in love with Rust by flohofwoe on Thursday November 22, 2018 @04:38AM (#18508951)
It depends heavily on how you're counting lines of code and what C++ features you're using.

If you include a couple of C++ stdlib headers you're already well past 45kloc per compilation unit (for instance, including <vector> pulls in about 25kloc of code). Such a file usually compiles in a second or so, but the problem in C++ projects is that each source file pulls in the same headers over and over, which explodes the line count the compiler has to crunch through (I bet that in most bigger C++ projects, the actual project code is less than 5% of what the compiler actually needs to compile).

C is much more predictable, a 45kloc C project should compile and link in under a second for a full rebuild without optimizations, and at most 2..3 seconds with optimizations. The link-step is usually the critical part, since that's hard to speed up by throwing more hardware resources at it.

Re:Still in love with Rust by danieldk on Thursday November 22, 2018 @03:51AM (#18508752)
I have some projects of that size (ballpark), typically using some Boost (but not heavy on meta programming), Qt, and the likes. A fresh non-incremental compile usually takes less than a minute.

I have Rust projects that are many times smaller but take much more time for a non-incremental build. Of course, a large difference is that a fresh Rust build (after a cargo clean) compiles all its dependent crates, whereas many C/C++ libraries are provided pre-compiled by whatever system you are compiling on.

Re:Still in love with Rust by EugeneOZ on Thursday November 22, 2018 @03:57AM (#18508774)
Well, what is the point in this comparison then? I'm not trying to say Rust is the fastest compiler on the planet, but really people don't even try to be objective.
Re:Still in love with Rust by majewsky on Thursday November 22, 2018 @04:53AM (#18509012)
If you're comparing, say, a 10 KLOC C++ program vs. a 10 KLOC Rust program, then the comparison is fair IMO. The end user doesn't care whether Rust chooses a different compilation strategy for dependencies.
Re:Still in love with Rust by EugeneOZ on Thursday November 22, 2018 @05:08AM (#18509062)
End users run "cargo clean" really rare (I can't even name examples - really rare). If we compare regular compilation in C++, then we should take regular compilation in Rust, not something exceptional.
Re:Still in love with Rust by Jyaif on Thursday November 22, 2018 @08:00AM (#18509724)
~100k loc takes 40 secs with `make -j 4` on my laptop.
Re:Still in love with Rust by EugeneOZ on Thursday November 22, 2018 @10:46AM (#18510619)
Finally some numbers, thanks. Yes, Rust compilation is slower.
Re:Still in love with Rust by jerrre on Thursday November 22, 2018 @04:02AM (#18508794)
Like the others say: depends. But wasn’t saying C++ compiles faster, just that I know from experience that anything over a couple of seconds can ruin your flow.
Re:Still in love with Rust by sifoobar on Thursday November 22, 2018 @04:15AM (#18508856)
No shit, I recently restarted a project [0] in straight C after giving it a serious try in C++. It's been a while since I dipped my toes, but a couple of weeks of decoding screens upon screens of template instantiations for every single compilation error and waiting minutes for a fresh build brings back memories. I'm not touching that madness with a ten foot pole again, they have some kind of crazy cult thing going where everyone agreed to pretend it's all good. Compiling the same thing in C is instant, I don't even want to think about how much time I wasted.

[0] https://gitlab.com/sifoo/snigl

Re:Still in love with Rust by EugeneOZ on Thursday November 22, 2018 @04:18AM (#18508863)
Well, if you can't even call a range (seconds, minutes, hours) then I can say that Rust is more predictable at least :)

Couple of seconds for 45k lines - I think you are too demanding :) But if C++ can compile it in couple of seconds - great, good competition for Rust :)

Re:Still in love with Rust by adrianN on Thursday November 22, 2018 @03:45AM (#18508731)
That really heavily depends on the kind of code. Template metaprogramming slows down the compiler a lot.
Re:Still in love with Rust by EugeneOZ on Thursday November 22, 2018 @03:50AM (#18508748)
So sometimes it takes couple of seconds, sometimes couple of hours? Maybe there's some approximate range.
Re:Still in love with Rust by skrimp on Thursday November 22, 2018 @04:17AM (#18508860)
C++ compile times heavily depend on the code that is being compiled and the build system that is compiling it. Code that doesn't touch STL or boost or do much metaprogramming of its own is going to compile extremely fast (especially when compiled in parallel). Code that pulls in half of boost isn't going to compile so quick without tweaking the build settings. Due to how variable compilation times are, I don't think the range you provided is that unreasonable. Build time is something that changes on a project to project basis.