News for hackers. Stuff that matters.

vegerot

Re:C++ vs. Rust Build Times on Friday January 06, 2023 @07:11PM (#34283302)
Agreed! …but while we’re at it curly gang all day
Re:C++ vs. Rust Build Times on Friday January 06, 2023 @07:09PM (#34283278)
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

Re:C++ vs. Rust Build Times on Friday January 06, 2023 @07:04PM (#34283235)
> 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

Re:C++ vs. Rust Build Times on Friday January 06, 2023 @06:59PM (#34283191)
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!
Re:C++ vs. Rust Build Times on Friday January 06, 2023 @06:56PM (#34283157)
Do they compile fast? If not, why not just use Rust? The author said he’ll switch to Rust when the compilation speed improves
Re:C++ vs. Rust Build Times on Friday January 06, 2023 @06:55PM (#34283148)
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.

Re:C++ vs. Rust Build Times on Friday January 06, 2023 @06:53PM (#34283138)
Martin?
Re:C++ vs. Rust Build Times on Friday January 06, 2023 @06:51PM (#34283120)
I think you two are talking past each other. He’s talking about hypotheticals, and you’re talking about what’s more common
Re:C++ vs. Rust Build Times on Friday January 06, 2023 @06:49PM (#34283098)
“opt-in” in the sense that I could just multiple versions of my functions if I want to? Agreed!
Re:C++ vs. Rust Build Times on Friday January 06, 2023 @06:48PM (#34283087)
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

Re:C++ vs. Rust Build Times on Friday January 06, 2023 @01:48PM (#34279073)
cool! Does quick-lint use this pattern? https://github.com/quick-lint/cpp-vs-rust
Re:C++ vs. Rust Build Times on Friday January 06, 2023 @01:01PM (#34278421)
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

Re:C++ vs. Rust Build Times on Friday January 06, 2023 @12:59PM (#34278395)
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

Re:C++ vs. Rust Build Times on Friday January 06, 2023 @12:54PM (#34278304)
The article breaks down how much time is spent by each part of the compiler (borrow checking, LLVM, macro expansion, etc.) check it out!
Re:C++ vs. Rust Build Times on Friday January 06, 2023 @12:53PM (#34278271)
#itdepends on the kind of software you’re making
Re:C++ vs. Rust Build Times on Friday January 06, 2023 @05:25AM (#34273093)
And all of them combined compile faster than either of these implementations!
Re:C++ vs. Rust Build Times on Friday January 06, 2023 @05:13AM (#34273020)
The specific time borrow check takes is in the article. Check out the section on “ Cranelift backend”
Re:C++ vs. Rust Build Times on Friday January 06, 2023 @05:12AM (#34273012)
No need to speculate These timings are all in the paper! Check the “Cranelift backend” section
Re:C++ vs. Rust Build Times on Friday January 06, 2023 @03:07AM (#34272205)
They should rewrite it in Rust
Re:C++ vs. Rust Build Times on Friday January 06, 2023 @02:48AM (#34272067)
> 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

Re:C++ vs. Rust Build Times on Friday January 06, 2023 @02:06AM (#34271822)
Re:C++ vs. Rust Build Times on Friday January 06, 2023 @01:45AM (#34271734)
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?
Re:C++ vs. Rust Build Times on Friday January 06, 2023 @12:48AM (#34271461)
Thank you for finally talking about this! I appreciate it, thanks
Re:Ask HN: Does Hacker News still do in person meet ups? on Tuesday September 20, 2022 @03:45AM (#32908852)
I’d be down for a spot between Menlo Park and SJ. Don’t really wanna go all the way to SF