This is, more or less, how I learned Rust circa 2015 (might have been a couple years later). I quickly started to write programs like I would have in C but got completely thwarted by the borrow checker because I wanted pointers everywhere. This made me throw my hands up and leave for other languages. However, 8 years later I did eventually come to love rust after learning the One Weird Trick of using indices instead…
A half-hour to learn Rust (2020)
41–50 of 86 posts
Re: A half-hour to learn Rust (2020)
#42This might not be a popular opinion, but - I love the idea of Rust, but the language itself seems needlessly complex to me. It looks like the authors tried to cover so many esoteric usecases that the result is more like C++ than C (which is not good in my eyes). One example: > `let` patterns can be used as conditions in `if`: Anyway, this tutorial looks great, I'll give Rust another go when I have a good project for…
Not sure if I disagree but your example is terrible. Let patterns in if statements greatly simplify things. The alternatives are a lot more convoluted. See example from code I wrote this week: https://github.com/trane-project/trane/blob/master/src/data/... Without the let, I'd have to do a match statement followed by an unwrap just to check if a field in an enum is set.
You... would not?
An `if let` trivially desugars to a `match`.
if let = {
...
}
becomes match {
=> {
...
}
_ => {}
}Re: A half-hour to learn Rust (2020)
#43This might not be a popular opinion, but - I love the idea of Rust, but the language itself seems needlessly complex to me. It looks like the authors tried to cover so many esoteric usecases that the result is more like C++ than C (which is not good in my eyes). One example: > `let` patterns can be used as conditions in `if`: Anyway, this tutorial looks great, I'll give Rust another go when I have a good project for…
> One example: Your example is a minor but quite useful piece of syntactic sugar, which was introduced a few years in following a similar construct being successful in Swift. You can read the entire reasoning at https://rust-lang.github.io/rfcs/0160-if-let.html
Re: A half-hour to learn Rust (2020)
#44This might not be a popular opinion, but - I love the idea of Rust, but the language itself seems needlessly complex to me. It looks like the authors tried to cover so many esoteric usecases that the result is more like C++ than C (which is not good in my eyes). One example: > `let` patterns can be used as conditions in `if`: Anyway, this tutorial looks great, I'll give Rust another go when I have a good project for…
Well, I have to agree Rust isn't one of the simplest PL-s on the planet. This is due to the fact that it is quite a modern PL and quite a versatile PL, supporting elements of functional programming, trait-oriented (conditional generics) programming, asynchronous programming, etc. and a capable standard library on top of it all. It takes, indeed, quite some time to take all of that Rust in. As a reward, you get a lot of expressiveness and the capability to discover a significant percentage (if not an overwhelming majority) of your programming mistakes at compile time as opposed to runtime (unit/integration tests or Q/A), which to me is priceless.
Nevertheless, from my experience, Rust is, at the same time, one of the most... "consistent", "predictable", "internally symmetric" PL-s I have ever seen. I consider Rust to be way easier to learn than, say, Swift.
> `let` patterns can be used as conditions in `if`
I somewhat cannot help it but feel that such an example should not be used in an introductory tutorial. `if let` is usually used to pattern-match a simple `enum`[1], not a complex `struct` that looks "dense" unless you're used to it.
Re: A half-hour to learn Rust (2020)
#45This might not be a popular opinion, but - I love the idea of Rust, but the language itself seems needlessly complex to me. It looks like the authors tried to cover so many esoteric usecases that the result is more like C++ than C (which is not good in my eyes). One example: > `let` patterns can be used as conditions in `if`: Anyway, this tutorial looks great, I'll give Rust another go when I have a good project for…
Re: A half-hour to learn Rust (2020)
#46I know this is not going to make me an expert in Rust. That'll probably take 10 years. But this is just the kind of thing I was looking for to get started with Rust. Thanks for sharing it here.
Re: A half-hour to learn Rust (2020)
#47This might not be a popular opinion, but - I love the idea of Rust, but the language itself seems needlessly complex to me. It looks like the authors tried to cover so many esoteric usecases that the result is more like C++ than C (which is not good in my eyes). One example: > `let` patterns can be used as conditions in `if`: Anyway, this tutorial looks great, I'll give Rust another go when I have a good project for…
> when I have a good project for it
... is a bad idea. I've heard this from several programmers who now use Rust professionally, but don't have first-hand experience about it. Their take can be boiled down to:
Rust has a learning curve that will mean that the first version will invariably be throw-away. Developing a mental model for how to change memory management structures to please the borrow checker and properly encode ownership seems like the biggest hurdle to writing good Rust.
I believe this is the main reason Rust adoption isn't skyrocketing, but still growing. The "onboarding" for Rust is more labor intensive and therefore disincentivizes its use.
Re: A half-hour to learn Rust (2020)
#48Earlier quoted context omitted.
That's perhaps the most pressing problem of Rust: not providing a concrete specification that can be targeted by projects and implementations.
That's indeed a problem, but I don't think it's the most pressing one, since it's common to the majority of widely-used languages.
I don't think so.
Both C and C++ are specified in international standards. That's the gold standard.
Java has very concrete versioning and specification process.
Python is also exemplary in its release and versioning process.
C# even breaks down versioning in terms of both CLR and fundamental frameworks.
Exactly which widely used language do you think is missing from that list?
Re: A half-hour to learn Rust (2020)
#49Earlier quoted context omitted.
That's perhaps the most pressing problem of Rust: not providing a concrete specification that can be targeted by projects and implementations.
I get the impression that Rust revisions are (at least intended to be?) backwards compatible: [0] Are there are good workarounds when breaking changes to occur? No idea if/how well breaking language changes can be isolated to stay within individual crates. [0] https://subscription.packtpub.com/book/programming/978178934...
I don't think that matters at all. If I try to build a new project with an older version of Rust, the compiler will still throw errors when stumbling upon newer features.
Re: A half-hour to learn Rust (2020)
#50This might not be a popular opinion, but - I love the idea of Rust, but the language itself seems needlessly complex to me. It looks like the authors tried to cover so many esoteric usecases that the result is more like C++ than C (which is not good in my eyes). One example: > `let` patterns can be used as conditions in `if`: Anyway, this tutorial looks great, I'll give Rust another go when I have a good project for…
Not sure if I disagree but your example is terrible. Let patterns in if statements greatly simplify things. The alternatives are a lot more convoluted. See example from code I wrote this week: https://github.com/trane-project/trane/blob/master/src/data/... Without the let, I'd have to do a match statement followed by an unwrap just to check if a field in an enum is set.