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?
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.
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.
Not every distribution is Debian Stable.
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.
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.
I think it's still recommended to use rustup.
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.
Last time I checked (6 month ago), the Rust AVR fork had just been merged upstream. This removed the necessity to build a forked rustc from a patched llvm.
I would have to re-check recent updates, but at the time there were still a lot of bugs, no core libs, etc.
That's not what I would call "full support".
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!
For me it was specially nice to have some minutes shaved off from full builds.
(Yes, I know that "unstable" in slice::select_nth_unstable refers to unstable sorting.)
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.)
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.
This issue though prevents me from recommending Rust for closed source development to my colleagues: https://github.com/rust-lang/rust/issues/40552
[0] https://www.reddit.com/r/adventofcode/comments/kj53l1/unoffi...
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.
And I just wish generic type parameters wouldn't have to be propagated through all types touching them.
That said I'm really happy with how it develops and Rust comes with many little details that I sorely miss in other languages. Thanks for all the effort.
I'm still figuring my way around rust so obviously some noob questions follow: -> what's with the move/copy mess ? I know why they are needed but it seem to be in the face with all the explicit '&' all over the place in any reasonably sized code. Why not hide it a bit by letting the implicit copy to happen to simpler structures ? (at compile time).
-> Why no love for inheritance? :) - it makes certain patterns easier to implement
-> Why no love for global/static variables ? I know they are prone to be misused but some patterns like singleton really need a lot of shortcuts to implement. And there will always be some cases where you want to keep variables with static and global scope
* Into, with s.into()
* An inherent method, .as_str()
* Deref coercion, &s
* Reborrowing, &*s (this builds on Deref too but isn't a coercion and can be done in places where coercion doesn't kick in)
... and probably some others I'm forgetting.
- 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.
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)
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.
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.
why ? do they charge you by the feature ?
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...
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");For those reading along (not Steve) expect does do that, but using the Debug formatter instead of Display, as the grandparent used.
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.
You still have languages that can't (really) even do async/threaded computation (Python, PHP, JavaScript/Node can't do threads AFAIK).
I've said this before: "Rust is the highest level low level language I've ever used. Java is the lowest level high level language I've ever used."
enum Result<T, E> {
Ok(T),
Err(E),
}
match header.get(0) {
None => Err("invalid header length"),
Some(&1) => Ok(Version::Version1),
Some(&2) => Ok(Version::Version2),
Some(_) => Err("invalid version"),
}
I wasn't saying it was bad, just a pain point for me.Jokes aside there are many helper methods on `Result` to make it more Rustic, try looking into: https://doc.rust-lang.org/std/result/enum.Result.html