Live data from Hacker News

A half-hour to learn Rust (2020)

fasterthanli.me

21–30 of 86 posts

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

#22
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…

Can you contrast between both approaches? How can i use indices instead of pointers? Where can i learn more?

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

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

(I'm learning Rust by implementing a simple Lisp interpreter in it)

I think TFA is a great resource in terms of presenting syntax and idioms. My biggest problem with learning Rust though has been understanding how to do things when the borrow checker prohibits the solution that would be 'obvious' in C#, C++, etc. I started to make progress when I bought the O'Reilly Programming in Rust book, and then thoroughly read and re-read the chapter on memory management.

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

#25
Feels like every language should have an introduction like this. It's frustrating that lang intros are either your very basic and trivial example, or a full-blown set of tutorials, nothing in-between.

I also chuckled at the "20 minute read".

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

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

How would memory management work without the borrow checker?

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

#27
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

I've been writing JS for 17 (continuous) years I'd say it took me at the very least 6, probably much closer to 10, to get to what I'd call "expert" JS knowledge (and have since regressed somewhat).

I've been using other languages longer than 10 years too but not continuously enough to ever consider myself expert.

I'd say there are definitely rust experts out there, but I'd posit it's unlikely for the average dev to have gotten that far yet.

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

#28
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 it, but to me it seems there is a great need for a simpler language with similar memory management. Rust is just too complex, imho.

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

#29
post #20

Previous discussion with 333 comments (2021): https://news.ycombinator.com/item?id=25610741

Thanks! Macroexpanded:

A half-hour to learn Rust - https://news.ycombinator.com/item?id=25610741 - Jan 2021 (330 comments)

A half-hour to learn Rust - https://news.ycombinator.com/item?id=22448933 - Feb 2020 (148 comments)

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

#30
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 all there's to it. It's like trying to learn to play the guitar without reading a book on guitar cords, pulling guitar strings individually at random - the music just won't happen for quite a long time, unless you're Mozart. At any rate, one can always forget Rust references (i.e., raw pointers) and use Rust reference-counted smart pointers[1], effectively writing Rust analogously to Swift.

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

Post reply on HN