Most active commenters
  • Seattle3503(3)

←back to thread

611 points LorenDB | 27 comments | | HN request time: 0.001s | source | bottom
Show context
dvratil ◴[] No.43908097[source]
The one thing that sold me on Rust (going from C++) was that there is a single way errors are propagated: the Result type. No need to bother with exceptions, functions returning bool, functions returning 0 on success, functions returning 0 on error, functions returning -1 on error, functions returning negative errno on error, functions taking optional pointer to bool to indicate error (optionally), functions taking reference to std::error_code to set an error (and having an overload with the same name that throws an exception on error if you forget to pass the std::error_code)...I understand there's 30 years of history, but it still is annoying, that even the standard library is not consistent (or striving for consistency).

Then you top it on with `?` shortcut and the functional interface of Result and suddenly error handling becomes fun and easy to deal with, rather than just "return false" with a "TODO: figure out error handling".

replies(24): >>43908133 #>>43908158 #>>43908212 #>>43908219 #>>43908294 #>>43908381 #>>43908419 #>>43908540 #>>43908623 #>>43908682 #>>43908981 #>>43909007 #>>43909117 #>>43909521 #>>43910388 #>>43912855 #>>43912904 #>>43913484 #>>43913794 #>>43914062 #>>43914514 #>>43917029 #>>43922951 #>>43924618 #
1. 90s_dev ◴[] No.43908540[source]
I like so much about Rust.

But I hear compiling is too slow.

Is it a serious problem in practice?

replies(9): >>43908584 #>>43908616 #>>43908634 #>>43908644 #>>43908690 #>>43908851 #>>43909184 #>>43910126 #>>43927094 #
2. zozbot234 ◴[] No.43908584[source]
People who say "Rust compiling is so slow" have never experienced what building large projects was like in the mid-1990s or so. It's totally fine. Besides, there's also https://xkcd.com/303/
replies(2): >>43908701 #>>43908824 #
3. mynameisash ◴[] No.43908616[source]
It depends on where you're coming from. For me, Rust has replaced a lot of Python code and a lot of C# code, so yes, the Rust compilation is slow by comparison. However, it really hasn't adversely affected (AFAICT) my/our iteration speed on projects, and there are aspects of Rust that have significantly sped things up (eg, compilation failures help detect bugs before they make it into code that we're testing/running).

Is it a serious problem? I'd say 'no', but YMMV.

4. Seattle3503 ◴[] No.43908634[source]
Absolutely, the compile times are the biggest drawback IMO. Everywhere I've been that built large systems in Rust eventually ends up spending a good amount of dev time trying to get CI/CD pipeline times to something sane.

Besides developer productivity it can be an issue when you need a critical fix to go out quickly and your pipelines take 60+ minutes.

replies(4): >>43908723 #>>43908757 #>>43910113 #>>43913607 #
5. cmrdporcupine ◴[] No.43908644[source]
I worked in the chromium C++ source tree for years and compiling there was orders of magnitude slower than any Rust source tree I've worked in so far.

Granted, there aren't any Rust projects that large yet, but I feel like compilation speeds are something that can be worked around with tooling (distributed build farms, etc.). C++'s lack of safety and a proclivity for "use after free" errors is harder to fix.

replies(1): >>43909891 #
6. kelnos ◴[] No.43908690[source]
Compilation is indeed slow, and I do find it frustrating sometimes, but all the other benefits Rust brings more than make up for it in my book.
7. kelnos ◴[] No.43908701[source]
Not really relevant. The benchmark is how other language toolchains perform today, not what they failed to do 30 years ago. I don't think we'd find it acceptable to go back to mid-'90s build times in other languages, so why should we be ok with it with something like Rust?
8. ◴[] No.43908723[source]
9. lilyball ◴[] No.43908757[source]
Don't use a single monolithic crate. Break your project up into multiple crates. Not only does this help with compile time (the individual crate compiles can be parallelized), it also tends to help with API design as well.
replies(2): >>43908980 #>>43909085 #
10. creata ◴[] No.43908824[source]
Or maybe they have experienced what it was like and they don't want to go back.
11. juliangmp ◴[] No.43908851[source]
I can't speak for a bigger rust project, but my experience with C++ (mostly with cmake) is so awful that I don't think it can get any worse.

Like with any bigger C++ project there's like 3 build tools, two different packaging systems and likely one or even multiple code generators.

replies(1): >>43914904 #
12. mixmastamyk ◴[] No.43908980{3}[source]
It compiles different files separately, right?

With some exceptions for core data structures, it seems that if you only modified a few files in a large project the total compilation time would be quick no matter how slow the compiler was.

replies(1): >>43909112 #
13. Seattle3503 ◴[] No.43909085{3}[source]
Every project I've worked on used a workspace with many crates. Generally that only gets you so far on large projects.
14. conradludgate ◴[] No.43909112{4}[source]
Sorta. The "compilation unit" is a single crate, but rustc is now also parallel, and LLVM can also be configured to run in parallel IIRC.

Rust compile times have been improving over time as the compiler gets incrementally rewritten and optimised.

15. conradludgate ◴[] No.43909184[source]
It is slow, and yes it is a problem, but given that typical Rust code generally needs fewer full compiles to get working tests (with more time spent active in the editor, with an incremental compiler like Rust Analyzer) it usually balances out.

Cargo also has good caching out of the box. While cargo is not the best build system, it's an easy to use good system, so you generally get good compile times for development when you edit just one file. This is along made heavy use of with docker workflows like cargo-chef.

16. gpderetta ◴[] No.43909891[source]
Are there rust projects that are within orders of magnitude of Chromium?
replies(1): >>43920902 #
17. nicoburns ◴[] No.43910113[source]
If you have the money to throw at it, you can get a long way optimising CI pipelines just by throwing faster hardware at it. The sort of server you could rent for ~$150/month might easily be ~5x faster than your typical Github Actions hosted runner.
replies(2): >>43910741 #>>43914316 #
18. throwaway76455 ◴[] No.43910126[source]
Compile times are the reason why I'm sticking with C++, especially with the recent progress on modules. I want people with weaker computers to be able to build and contribute to the software I write, and Rust is not the language for that.
replies(1): >>43927109 #
19. Seattle3503 ◴[] No.43910741{3}[source]
Yes, this is often the best "low-hanging fruit" option, but it can get expensive. It depends how you value your developer time.
20. sethammons ◴[] No.43913607[source]
We have 60 minutes deploy pipelines and are in python. Just mentioning that since, in theory, we are not penalized for long compile times.

Fast ability to quickly test and get feedback is mana from the gods in software development. Organizations should keep it right below customer satisfaction and growth as a driving metric.

21. hobofan ◴[] No.43914316{3}[source]
Besides faster hardware, one of the main features (and drawbacks) you get with self-hosted runners is the option to break through build isolation, and have performant caches between builds.

With many other build systems I'd be hesitant to do that, but since Cargo is very good about what to rebuild for incremental builds, keeping the cache around is a huge speed boost.

22. thawawaycold ◴[] No.43914904[source]
that does not answer at all OP's question.
replies(1): >>43924696 #
23. alpaca128 ◴[] No.43920902{3}[source]
Almost a quarter of Firefox' compiled code is Rust: https://4e6.github.io/firefox-lang-stats/
replies(1): >>43924242 #
24. gpderetta ◴[] No.43924242{4}[source]
Nice. That's more than I expected. What's the compilation time compared to, say, the c++ portion?
25. juliangmp ◴[] No.43924696{3}[source]
"It can't get any worse than C++" That's my response. So just use rust. In the long run you'll save time as well.
26. ttfkam ◴[] No.43927094[source]
Yes, Rust compiling is slow. Then again, I wouldn't say that C++ is exactly speedy in that area either. Nor Java. None of those are even in the same zip code to Go's compile speed.

So if you're cool with C++ or Java compile times, Rust will generally be fine. If you're coming from Go, Rust compiles will fell positively glacial.

27. ttfkam ◴[] No.43927109[source]
C++ compiles quickly? News to me.