News for hackers. Stuff that matters.
Re:Rust Is Surprisingly Good as a Server Language by felipellrocha on Monday July 13, 2020 @03:44AM (#23818161)
Man... I hear you, but this is only a problem compiling from a cold cache. From a warm cache, it really isn't a problem anymore.
Re:Rust Is Surprisingly Good as a Server Language by johnfn on Monday July 13, 2020 @03:47AM (#23818191)
No, it's an issue for warm caches as well. I had a 10 second compilation cycle to add a comment to a file in a project with a couple hundred lines of code and like 4 lines in my cargo.toml. 10 seconds! For a few hundred lines! Maybe that doesn't sound insane, but extrapolating out, that's at least 100x worse than the languages that I'm used to.

(I know that compilation speed is a Hard Problem, I know that I'm comparing apples to oranges, I know that Rust does fancy magic that other languages could only dream of. But everything that slow compiles buy me won't get bring me back flow state.)

Re:Rust Is Surprisingly Good as a Server Language by DougBTX on Monday July 13, 2020 @03:52AM (#23818232)
If it is a project you’ve recently built, it shouldn’t matter what’s in your cargo file, since none of that will change from build to build. I wonder what’s broken. How long does it take to build a new empty project?

One think that’s helped me stay “in the flow” is switching to rust-analyzer instead of the current official RLS. Much faster, I leave format on save turned on, so `cargo check` output is usually ready in about a quarter of a second after save.

Re:Rust Is Surprisingly Good as a Server Language by johnfn on Monday July 13, 2020 @03:59AM (#23818296)
A new empty project compiles in under a second. However, adding dependencies will add some arbitrary number to this. Additionally, every hundred lines of code seems to add some amount of time between half a second and a whole second. I did some reading and read that generics are particularly expensive to compile, so I wonder if that accounts for the variance. I can't explain why cargo deps add time, though.

I LOVE rust-analyzer. It's actually what got me to reconsider Rust after I tried a year or two ago, and it is SO good.

Re:Rust Is Surprisingly Good as a Server Language by steveklabnik on Monday July 13, 2020 @08:01AM (#23819805)
Let me put it a stronger way: if you're seeing your cargo dependencies recompile every time, it is a bug. Please file one upstream. These bugs do happen, but they are bugs.
Re:Rust Is Surprisingly Good as a Server Language by johnfn on Monday July 13, 2020 @01:33PM (#23823291)
I don't literally see my deps compile. It's just that compile time gets slower. (I wonder if it's related to the linker?) Is that still a bug? Would be happy to report it if so.
Re:Rust Is Surprisingly Good as a Server Language by estebank on Monday July 13, 2020 @02:31PM (#23823977)
If the slowless you're seeing is caused by the linker, which can very well be the case, consider using LLD as you can see significant speed improvements to the linking step.

https://github.com/rust-lang/rust/issues/39915#issuecomment-...

https://doc.rust-lang.org/1.22.0/unstable-book/compiler-flag...

If installed, you can run

    RUSTFLAGS="-Clink-arg=-fuse-ld=lld" cargo build --release
Re:Rust Is Surprisingly Good as a Server Language by johnfn on Monday July 13, 2020 @03:21PM (#23824530)
Looked into this :) unfortunately I run Mac so there's nothing I can do here. Tempted to dual boot Ubuntu, though.
Re:Rust Is Surprisingly Good as a Server Language by estebank on Monday July 13, 2020 @05:01PM (#23825515)
It's a shame. I'm on the same boat and not being able to use lld adds a literal minute to my builds :-/
Re:Rust Is Surprisingly Good as a Server Language by steveklabnik on Monday July 13, 2020 @02:10PM (#23823719)
Ahh.

I am less sure, but I would think that's expected, given that it has to link everything together into the final binary. You're gonna end up giving the linker more work to do, as you suspected.

Re:Rust Is Surprisingly Good as a Server Language by teraku on Monday July 13, 2020 @04:15AM (#23818393)
What? I have a ~1k LOC program which consists of 4 modules, 3 of them all importing the 4th and in total ~200 dependencies. With a warm cache my program takes ~2s to compile. Cold-cache is about 18s
Re:Rust Is Surprisingly Good as a Server Language by johnfn on Monday July 13, 2020 @01:51PM (#23823501)
Interesting! I wonder if I was hitting some pathological case with my dependency tree.
Re:Rust Is Surprisingly Good as a Server Language by lenkite on Monday July 13, 2020 @08:46AM (#23820156)
Rust compilation times as they stand today are actually worse than C++. C++ also offers flexibility to an engineer to reduce compilation times significantly via use of techniques like shared headers, etc.
Re:Rust Is Surprisingly Good as a Server Language by _-___________-_ on Monday July 13, 2020 @03:56AM (#23818266)
> I had a 10 second compilation cycle to add a comment to a file in a project with a couple hundred lines of code and like 4 lines in my cargo.toml.

Why compile again after adding a comment?

Re:Rust Is Surprisingly Good as a Server Language by im3w1l on Monday July 13, 2020 @07:10AM (#23819449)
In fast-compiling languages, it's viable to have recompile-on-file-save or even continuous recompilation. Modern (and they aren't that modern anymore) IDE's will show red squiggles under code with compilation errors without requiring any action at all.
Re:Rust Is Surprisingly Good as a Server Language by mlindner on Monday July 13, 2020 @08:41AM (#23820106)
That's already provided by other tools than the compiler like rust analyzer.
Re:Rust Is Surprisingly Good as a Server Language by johnfn on Monday July 13, 2020 @01:52PM (#23823515)
This was meant as an example, not something I'd literally do.

The most common trivial change would be to add a dbg! statement.

Re:Rust Is Surprisingly Good as a Server Language by bluecmd on Monday July 13, 2020 @03:59AM (#23818297)
Build systems usually don't care what you added. Modification of source means rebuild.
Re:Rust Is Surprisingly Good as a Server Language by _-___________-_ on Monday July 13, 2020 @04:31AM (#23818500)
Yes, but the programmer knows what they added, and I was asking why they wanted to build again if all they added was a comment? If this was in a CI context then 10 seconds seems unimportant; compile times of 10 seconds are usually only complained about in the context of programmers who've gotten used to tiny edit-compile-test cycles.
Re:Rust Is Surprisingly Good as a Server Language by entha_saava on Monday July 13, 2020 @06:24AM (#23819172)
In order to ensure the next rebuild on an actual code change doesn't need to compile this comment-changed file, I guess.