HNHacker News
TopNewBestAskShowJobs

vegerot

16 karma · joined May 26, 2022

submissionscomments
vegerot··on A practical comparison of build and test speed between C++ and Rust
Agreed! …but while we’re at it curly gang all day
vegerot··on A practical comparison of build and test speed between C++ and Rust
Thank you for actually suggesting something! Many people say “this is unidiomatic/slow/unoptimal” but nobody is giving specifics. Thanks :)

btw the author is looking to improve the Rust version and is accepting contributions in that repo if you wanna improve the experiment

vegerot··on A practical comparison of build and test speed between C++ and Rust
> If I made the C++ code use a custom vector and the Rust code use the standard vector, then people would complain that the Rust code was artificially shorter.

People would also complain that even though you claim “my C++ code is longer than Rust but compiles just as fast”, you’re not factoring the extra things Rust’s versions do

vegerot··on A practical comparison of build and test speed between C++ and Rust
The author said he liked Rust and will switch to Rust if/when it builds faster than C++. So for the author at least, his answer is Rust!
vegerot··on A practical comparison of build and test speed between C++ and Rust
Do they compile fast? If not, why not just use Rust? The author said he’ll switch to Rust when the compilation speed improves
vegerot··on A practical comparison of build and test speed between C++ and Rust
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.

vegerot··on A practical comparison of build and test speed between C++ and Rust
Martin?
vegerot··on A practical comparison of build and test speed between C++ and Rust
I think you two are talking past each other. He’s talking about hypotheticals, and you’re talking about what’s more common
vegerot··on A practical comparison of build and test speed between C++ and Rust
“opt-in” in the sense that I could just multiple versions of my functions if I want to? Agreed!
vegerot··on A practical comparison of build and test speed between C++ and Rust
TIL. Thanks!

In my plebeian brain I just thought “monomorphization = static dispatch” / 0-cost abstraction (vs. just writing multiple versions of a function), which both Rust generics and C++ templates fall into.

Now I see that “monomorphization” has a specific definition in FPL

vegerot··on A practical comparison of build and test speed between C++ and Rust
cool! Does quick-lint use this pattern? https://github.com/quick-lint/cpp-vs-rust
vegerot··on A practical comparison of build and test speed between C++ and Rust
Something to stress is that the article is not just about compile times. It’s about compile+test times.

If Chrome were written in Python it’d be hella slower iteration times

vegerot··on A practical comparison of build and test speed between C++ and Rust
I think it depends on the kinds of projects you’re working on, and your developer workflow.

For small→medium projects I agree that Rust compile times are fine

vegerot··on A practical comparison of build and test speed between C++ and Rust
The article breaks down how much time is spent by each part of the compiler (borrow checking, LLVM, macro expansion, etc.) check it out!
vegerot··on A practical comparison of build and test speed between C++ and Rust
#itdepends on the kind of software you’re making
vegerot··on A practical comparison of build and test speed between C++ and Rust
And all of them combined compile faster than either of these implementations!
vegerot··on A practical comparison of build and test speed between C++ and Rust
The specific time borrow check takes is in the article. Check out the section on “ Cranelift backend”
vegerot··on A practical comparison of build and test speed between C++ and Rust
No need to speculate These timings are all in the paper! Check the “Cranelift backend” section
vegerot··on A practical comparison of build and test speed between C++ and Rust
They should rewrite it in Rust
vegerot··on A practical comparison of build and test speed between C++ and Rust
> maybe a more fair comparison wouldn't involve polymorphism in the rust code?

I think using features of the language is fair game

btw, don't C++ templates also use monomorphization? I agree C++'s implementation is "lower level" (from a compiler perspective) than Rust generics, but that's one of Rust's selling features

vegerot··on A practical comparison of build and test speed between C++ and Rust
or just https://smmry.com/https://quick-lint-js.com/blog/cpp-vs-rust... like I did
vegerot··on A practical comparison of build and test speed between C++ and Rust
What about the other way around? Trying to cripple rustc until its features are closer to clang's? For example, removing some of the sanitizers or borrow checker in rustc?
vegerot··on A practical comparison of build and test speed between C++ and Rust
Thank you for finally talking about this! I appreciate it, thanks
vegerot··on Ask HN: Does Hacker News still do in person meet ups?
I’d be down for a spot between Menlo Park and SJ. Don’t really wanna go all the way to SF