Live data from Hacker News

A half-hour to learn Rust (2020)

fasterthanli.me

31–40 of 86 posts

Re: A half-hour to learn Rust (2020)

#31

This 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…

> > `let` patterns can be used as conditions in `if`:

You can code without that, it's just that you are going to wish you had it after your first few programs.

> but the language itself seems needlessly complex to me

A lot of the complexity is around making the explicitness of the language bearable. If you had to be explicit without all the syntax sugar and type / lifetime inference it would be insufferable to program in.

Re: A half-hour to learn Rust (2020)

#32
post #9

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…

Isn't that one weird trick more or less defeating the whole purpose of rust's ownership/borrowing model by moving the problems one level up the ladder? Having seen that kind of opinion stated elsewhere, it seems what most people would like is rust minus borrowing, and I feel I would get behind that too.

> what most people would like is rust minus borrowing

It's already possible. Use Rust reference-counted smart pointers[1] for shareable immutable references and internal mutability[2] for non-shareable mutable references checked at runtime instead of compile time.

[1] https://doc.rust-lang.org/book/ch15-04-rc.html

[2] https://doc.rust-lang.org/book/ch15-05-interior-mutability.h...

Re: A half-hour to learn Rust (2020)

#33

This 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.

Re: A half-hour to learn Rust (2020)

#34

Earlier quoted context omitted.

Isn't that one weird trick more or less defeating the whole purpose of rust's ownership/borrowing model by moving the problems one level up the ladder? Having seen that kind of opinion stated elsewhere, it seems what most people would like is rust minus borrowing, and I feel I would get behind that too.

How would memory management work without the borrow checker?

Reference-counted[1], just like, say, Swift.

[1] https://en.wikipedia.org/wiki/Reference_counting

Re: A half-hour to learn Rust (2020)

#35
post #2

I 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.

If becoming an expert in Rust had to take 10 years, that would mean there are currently not a single Rust expert in the world

The current Rust experts probably spent more than 10 years learning the concepts that made them Rust experts.

Re: A half-hour to learn Rust (2020)

#36
post #9

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…

> got completely thwarted by the borrow checker IMvHO, Rust Ownership and Lifetime rules aren't really that hard to learn. The only trick is that a programmer cannot learn Rust exclusively by trial-and-error (which programmers love to do), trying dozens of syntax combinations to see what works. A programmer is forced to learn Rust by RTFM (which programmers hate to do), in order to understand how Rust works. That's a…

Rust has fabulous error messages, so I do a lot of programming by trial and error.

Re: A half-hour to learn Rust (2020)

#38
post #19
post #5

Earlier quoted context omitted.

And has it?

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.

Re: A half-hour to learn Rust (2020)

#39
post #19
post #5

Earlier quoted context omitted.

And has it?

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...

Re: A half-hour to learn Rust (2020)

#40

This 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

Post reply on HN