Hacker News new | ask | show | jobs
by ufo 2000 days ago
A question for the Rust crowd, from someone who's thinking about giving Rust another chance in 2021:

Last time I tried getting into Rust, some years ago, the recommended way to install it was to use the rustup tool. You were also kind of expected to learn using the "nightly" version of the language, because much of the documentation and stackoverflow answers depended on that.

Is this still the case now that we're about to enter 2021? Is it OK to learn rust by installing it via "apt install", or is it still recommended to use rustup? Is it OK to stick just to stable Rust or should I expect that I will need to install the nightly version at some point?

7 comments

I used Rust pretty regularly through 2020 at work and home, all with stable Rust.

All the stuff I did worked fine - 3D graphics with OpenGL and SDL2, web services with Hyper and Tokio (recently hit 1.0!), and CLI apps.

If you want to try apt install first, you can do that - It's easy to remove. But personally I do use rustup.

rustup is still the recommended way to install.

Rust has a 6 week release cadence, and while the language has settled down significantly over the last 1-2 years, there are still a lot of new features arriving that library maintainers are eager to use. Combined with performance improvements, you will almost always want to use a recent compiler.

Relatively slow moving package repositories are not a great fit for that reason. Rustup also handles installing support for various architectures - which are often not packaged well - and fast-moving tools like rust-analyzer.

The nightly situation has gotten much, much better though. Almost non of the popular crates still require nightly, and staying on stable is just fine for most projects.

(It's six weeks not three months)
Ah, right, thanks. I knew something about those 3 months bugged me.
> Relatively slow moving package repositories are not a great fit for that reason

Not every distribution is Debian Stable.

It seems that ubuntu 20.10 groovy gorilla is stuck at 1.43

As a library maintainer I need to make the choice of which version to target.

It's easy to accidently use features of a recent rust version, as you can see in this example:

https://github.com/mkmik/slyce/issues/17

I could work around this issue and pin the rustc version in the CI system to avoid regressions, but is it worth the effort since it's likely that this particular user will eventually depend on another library that uses a feature of >1.43 and thus eventually give in and use rustup? I want to be helpful towards users of my library, but I wonder if the most rational choice is to encourage users to upgrade the toolchain more liberally.

Yes, but some of them are, and some are even worse.
I haven't needed nightly much this year, except for an unstable platform (avr) not supported in stable. It has gotten much better and I feel there are very few reasons you might use nightly. Since often the packaged versions of the toolchain in distros are out of date and many crates take advantage of the newest features, I'd heavily recommend it.
even the rust-analyzer plugin for plugin for VSCode installs and runs without any fuss, definite improvement from when I last saw it in 2019.

Re: apt install - I never trust the OS packages for anything like developer tools, I'd rather have everything run out of my home directory. Then again, I'm not a C/C++ developer where the OS, libraries, build tools are all intertwined.

Regarding nightly:

https://blog.rust-lang.org/2020/12/16/rust-survey-2020.html

> the number of users who are relying on a nightly compiler at least part of the time continues to drop - down to 28% compared with last year’s 30.5% with only 8.7% of respondents saying they use nightly exclusively. When asked why people are using nightly the largest reason was to use the Rocket web framework which has announced it will work on the stable version of Rust in its next release. The next largest reason for nightly was const generics, but with a minimal version of const generics reaching stable, we should see less of a reliance on nightly for this feature.

TL;DR: unless you're doing certain specific things, stable Rust should work well for you.

Regarding rustup vs apt, you can absolutely install via apt if you want to. Depending on what version you get, you may or may not be far enough behind the rest of the world for it to be a pain. Which version you'll get depends on the specifics of the distro.

Basically nightlies are just like the "preview" features in Java, .NET and C++ ecosystems, or import from future in Python.
I've been using Rust since 2016 and I've never installed a nightly version for code I was writing. (I did install nightly for some code completion tool or something back in the day. Maybe Racer?)

I think it's still recommended to use rustup.

Stable rust is perfectly fine. The vast majority of Rust users are on stable only.
Unless you want to try out Rocket. That one STILL requires nightly...
Rocket 0.5 (which is coming soon) will compile on stable. Alternatively, you can the master git branch directly. Very few libraries still require nightly. Most of them have moved or are moving to stable.