top | item 25593031

Rust 1.49.0

241 points| pietroalbini | 5 years ago |blog.rust-lang.org

111 comments

order

nitsky|5 years ago

I am surprised the blog post doesn't mention the stabilization of binding both by-move and by-ref in patterns [1]. I have personally been waiting on this one for several years. Time to go remove my workarounds. Thanks!

[1]: https://github.com/rust-lang/rust/pull/76119

steveklabnik|5 years ago

There is always an art to what to decide to put in vs not, and it wasn't 100% clear to us how important folks consider this feature. We waffled a bit, it was basically a coinflip on putting it in or not.

ufo|5 years 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?

ReactiveJelly|5 years ago

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.

the_duke|5 years ago

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.

danhor|5 years ago

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.

Scuds|5 years ago

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.

steveklabnik|5 years ago

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.

ragnese|5 years ago

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.

rapsey|5 years ago

Stable rust is perfectly fine. The vast majority of Rust users are on stable only.

Galanwe|5 years ago

Any chance to see increased support for 8bit AVR in upcoming releases?

I know Rust is community driven, so it's not like contributions will appear from thin air. But I guess maybe it would be time to promote/incentivize people to contribute support for microcontrollers. This is a realm where C reigns and Rust would be a bowl of fresh air.

lights0123|5 years ago

Rust has full support for AVR, excluding function pointers due to current LLVM bugs. Building on stable would be nice though, as it currently requires a custom target JSON file.

steveklabnik|5 years ago

Folks are still working on it, yep.

I mean, Rust does have support for many microcontrollers. I do ARM stuff for work, for example. Just not AVR. It'll be nice to have it though!

pjmlp|5 years ago

Congratulations to everyone.

For me it was specially nice to have some minutes shaved off from full builds.

dbrgn|5 years ago

Rust, where even unstable functions can be stable!

(Yes, I know that "unstable" in slice::select_nth_unstable refers to unstable sorting.)

darksaints|5 years ago

Curious why the distinction between tier 1 and tier 2 targets is testing. Is testing that burdensome? Why can't the tests be run on them?

steveklabnik|5 years ago

The difference is not "testing" in a broad sense, the difference is "tests guaranteed to pass" vs "tests may run if they exist but we don't gate on them passing."

Being able to guarantee that they pass means having the expertise to fix any issues, and with a timeliness to be able to fix them and not block a release. That requires people around to support the target, with a higher burden than tier 2.

(Technically, it's even more than "not block a release" it's "not block any PR that may start failing on that target," since all tests must pass before a PR is landed.)

Diggsey|5 years ago

Commits don't reach master until they have passed all the test suites. As such, it is very burdensome to add more test suites: it increases the time taken to run the test suite and reduces the throughput of all rust development. Not to mention, many of the tier 2 or lower targets are not easy to run in CI.

You could ask: why aren't the tier 2 tests just run before release? But then, if they are broken it may be a significant amount of work to fix, and could delay the release.

Maybe there is a middle-ground where tier 2 tests are run daily, but then you need a team of people just to fix those tests, because it will no longer be on the original PR author to make sure those tests pass before their PR is merged.

nikic|5 years ago

An important factor here is hardware access. Tier 2 targets just produce cross-compilation artifacts, tier 1 targets require actual hardware to run on. For example, a tier 1 macos aarch64 target is impossible until the hardware can be run in CI, for every merge.

koenigdavidmj|5 years ago

Tier2 compiler can be built with a cross-compiler, perhaps, but you don’t have consistent access to hardware to run the tests on. Just a guess

kzrdude|5 years ago

CI is expensive, even more on those targets.

afavour|5 years ago

I think it’s that the tests aren’t run, and consequently, they don’t guarantee the tests pass, which means it might not behave exactly the same as a tier 1 platform. So the difference is bigger than just tests.

mindv0rtex|5 years ago

I really enjoy using Rust for personal side projects. It made me a better C++ developer. I'm excited about stabilized const generics to be able to speed up my linear algebra code.

This issue though prevents me from recommending Rust for closed source development to my colleagues: https://github.com/rust-lang/rust/issues/40552

steveklabnik|5 years ago

It is helpful to leave comments on issues like this, by the way.

Dowwie|5 years ago

A lot of people are using Rust for advent of code 2020. It's really interesting to see the role that AOC is having with adoption and leveling up Rust knowledge.

option_greek|5 years ago

I wish they would streamline the string handling capabilities. Currently the conversions between String and &str are really ugly to look at. In general the conversion between types don't seem all that great with developers having to either use crates or write their own code. They need to take more inspiration from C# which continues to be the benchmark of elegance (obviously personal opinion). That said, rust is still better than C++ - namely its package management is great. I just wish the compiler doesn't keep second guessing me :D

steveklabnik|5 years ago

> the conversions between String and &str are really ugly to look at.

This is entirely up to you; unless you find method calls ugly, in which case, you've got bigger problems :)

> They need to take more inspiration from C#

Could you elaborate a bit? I'm not familiar with what C# does here.

ChrisSD|5 years ago

I'm not sure what you mean by conversion between String and &str? To get an owned String from a &str you just use the `into` method, no?

apta_|5 years ago

What IDE do people use for rust nowadays?

UtherII|5 years ago

The IDE support use to be very poor but nowadays there are two really nice contenders :

- Jetbrains IDE with the Rust plugin (maintained by Jetbrains itself). The free IntelliJ IDE Community works really well. CLion or IntelliJ Ultimate are necessary for debugging support

- The Rust-analyser tool. A language server that can be used, in theory, on any IDE supporting the LSP protocol. Code is the most used IDE with this tool since it is the reference IDE of the project.

ibraheemdev|5 years ago

VS Code is one of the more popular ones, although it doesn't really qualify as an IDE. IntelliJ is probably the most popular IDE for Rust development.

k5z|5 years ago

Always Vim

deccanchargers|5 years ago

Nice.

Rust is nice language btw.

But,when will stable version of Rust be released? By stable,i mean, number of new features added must not be too much. Rust currently seem to be adding too many features every release (which is nice but also not so good at same time)

steveklabnik|5 years ago

> By stable,i mean, number of new features added must not be too much

What is "too much"? How many would you prefer? How does this release have too many features? This release has three, and they're all pretty small. Some could even argue that they may not even count as new features, but remove restrictions between combinations of existing features.

dbrgn|5 years ago

By that measure, both Java and JavaScript are highly unstable programming languages.

johnsoft|5 years ago

By this logic, languages are never "stable" until after they die

MetaDark|5 years ago

It sounds like your definition of stable applies to a very limited set of programming languages. The only thing I can think of that would fit that definition is C.

Have you seen how many new features have been added to C++20? (which is probably the closest language to Rust) Not to mention any of the dynamically typed languages.

jcelerier|5 years ago

> but also not so good at same time

why ? do they charge you by the feature ?

boxmonster|5 years ago

I recently wrote a utility for myself in Rust after having done several in C#. I like both languages, but Rust introduces pain points for no apparent reason. For example, I hate this way of dealing with errors

    match result {
        Ok(value) => value,
        Err(result) => { 
            panic!("error traversing directories {}", result);
        }
    };
It's awkward and ugly. I'm back to C#, now on .NET 5.) and find that it just got noticeably faster! It was already fast.

"Astonishing Performance of .NET 5: More Data"

https://medium.com/swlh/astonishing-performance-of-net-5-mor...

steveklabnik|5 years ago

This code is equivalent to

    result.unwrap_or_else(|e| panic!("error traversing directories {}", e));
There are a lot of methods on various types to reduce this kind of thing. If you didn't want to interpolate the value of e, it would be even simpler:

    result.expect("error traversing directories");

j1elo|5 years ago

"I recently wrote a utility for myself in ASM after having done several in C. I like both languages, but ASM introduces pain points for no apparent reason."

IMO the_duke summarized it perfectly in other comment: You are essentially complaining that Rust is not C#; Rust is much lower level and makes very different tradeoffs; most of the design decisions are there for a reason, and are good choices (https://news.ycombinator.com/item?id=25593825)

People considering Rust as an alternative for higher-level programming languages are in for a potential surprise or two. I guess this happens because Rust has received a lot of attention and promotion, enough to make some people consider it, where otherwise they wouldn't have thought of using tools that stand at a lower level than what is most appropriate for their needs (or knowledge).

EDIT: I've now read that in this particular case, the parent commenter is consciously playing with different languages to learn about them. Still, I think it would be a misconception to think that C# and Rust are at an equivalent level of programming abstraction, and thus should offer similar ergonomics.

rapsey|5 years ago

This is pretty nonsensical code so kind of hard to see what your point is.