Live data from Hacker News

Becoming Rustacean: Resources to Learn Rust Programming

nativebyx.dev

21–30 of 48 posts

Re: Becoming Rustacean: Resources to Learn Rust Programming

#21
post #16

The resources mentioned in this list are all pretty good. However, they might be intimidating for a beginner. A beginner wants one or two high quality sources to get started with. That's the Rust Book ( https://doc.rust-lang.org/stable/book/ ) or the interactive version of the same book ( https://rust-book.cs.brown.edu ) Also, not sure how this resource classifies Rust for Rustaceans as a beginner level book.

> Also, not sure how this resource classifies Rust for Rustaceans as a beginner level book.

Yeah. It still starts pretty shallow, but by page 33 it has a listing of a non-trivial manual implementation of Debug for some arbitrary type which is iterable, and that's not something a beginner would even need to write, let alone gain insight by having it dissected.

Re: Becoming Rustacean: Resources to Learn Rust Programming

#22
post #6
post #2

I really like the speed of rust. It’s very difficult to learn it though

The trick to learning Rust is to first start learning C++; that way your motivation to learn Rust increases even further and you start getting the feeling that Rust is easy ;) This is similar to the psychological trick of how an obese person, to make himself/herself feel better, stands next to an even more obese person :)

Not just any c++, I'd recommend performance aware modern c++. It leads towards the functional-ish zero-copy lock-free thinking rust rewards. I've been told ocaml or f# programmers also find rust easy.

Re: Becoming Rustacean: Resources to Learn Rust Programming

#23
post #13

Earlier quoted context omitted.

"the most difficult part was stopping myself from forcing aesthetical ideas of how to structure code from the other languages" Coming from C and PHP to JavaScript gave me similar cognitive dissonance. Syntactically these languages are very similar, but the semantics require to rethink quite much if what I learned.

Yeah, I wish there was a good list of things to hint you aren't being rusty. When you are cloning everything or have arc on everything that is a pretty good hint, but I'm sure someone could put together a better list than I could.

Clippy can help you to write more idiomatic Rust, so if you aren't already, definitely check out the clippy lints for a working program you wrote:

  cargo clippy
Clippy won't tend to spot unnecessary Arcs and similar architectural mistakes, however it would notice if you act as though things aren't Copy when they are [e.g. you've probably never 100.clone() but if you did Clippy would point out that's just 100 and the same would apply to types where it's less obvious that they're Copy and you might have forgotten]

Re: Becoming Rustacean: Resources to Learn Rust Programming

#24
post #11
post #10

Earlier quoted context omitted.

It is the speed of any compiled language to native code.

Oh, no, it isn't. Take the speed of Haskell or Prolog. They are much slower than Rust at runtime.

First of all Prolog is usually not AOT compiled rather JITed, secondly regarding Haskell, it is an issue with the skill set of the developer more than anything.

Re: Becoming Rustacean: Resources to Learn Rust Programming

#25
post #10

Earlier quoted context omitted.

It is the speed of any compiled language to native code.

I mean, that's probably true in some broad categorical sense, for the question of "speed of execution of final program" which it's not clear your parent meant. However it's not true in the specifics, there are so often little tweaks Rust has that otherwise comparable languages don't have that squeeze out a little better performance and this adds up. For example: C++ std::vector is a perfectly respectable growable arr…

Well I guess we can always play micro-benchmarks game if you want to go down that path, including selecting specific compiler toolchains and flags while making it a point that it is a property of language XYZ, to make it even better.

Re: Becoming Rustacean: Resources to Learn Rust Programming

#26
post #11

Earlier quoted context omitted.

Oh, no, it isn't. Take the speed of Haskell or Prolog. They are much slower than Rust at runtime.

There are even more: - Java (compiled AOT, anyone remembers how dead slow code GCJ produced?) - Go (not always as bad as Java, but not perfect either)

GCJ was always a toy compiler, if you want good AOT Java code check the commercial JDKs that have been in business for the last 20 years.

Re: Becoming Rustacean: Resources to Learn Rust Programming

#27
post #16

The resources mentioned in this list are all pretty good. However, they might be intimidating for a beginner. A beginner wants one or two high quality sources to get started with. That's the Rust Book ( https://doc.rust-lang.org/stable/book/ ) or the interactive version of the same book ( https://rust-book.cs.brown.edu ) Also, not sure how this resource classifies Rust for Rustaceans as a beginner level book.

> Also, not sure how this resource classifies Rust for Rustaceans as a beginner level book. Yeah. It still starts pretty shallow, but by page 33 it has a listing of a non-trivial manual implementation of Debug for some arbitrary type which is iterable, and that's not something a beginner would even need to write, let alone gain insight by having it dissected.

Agree. The author explicitly states its for experienced Rustaceans. Even the title makes that clear.

Re: Becoming Rustacean: Resources to Learn Rust Programming

#28

Earlier quoted context omitted.

Yeah, I wish there was a good list of things to hint you aren't being rusty. When you are cloning everything or have arc on everything that is a pretty good hint, but I'm sure someone could put together a better list than I could.

Clippy can help you to write more idiomatic Rust, so if you aren't already, definitely check out the clippy lints for a working program you wrote: cargo clippy Clippy won't tend to spot unnecessary Arcs and similar architectural mistakes, however it would notice if you act as though things aren't Copy when they are [e.g. you've probably never 100.clone() but if you did Clippy would point out that's just 100 and the s…

Yeah clippy is amazing, but I was thinking things everyone has to do sometimes in rust, but that if you find yourself having to resort to them often might be a hint that your overall paradigm might need a tweak to fit well. I didn't mean unnecessary arcs, but rather necessary ones. I find that if I donthings the way Ferris wants me to, that I dont have arc, rc, refcell, or clone very often, and nothing ends up needing to derive copy. When Ferris is happy my life is easier.

Re: Becoming Rustacean: Resources to Learn Rust Programming

#29
post #16

The resources mentioned in this list are all pretty good. However, they might be intimidating for a beginner. A beginner wants one or two high quality sources to get started with. That's the Rust Book ( https://doc.rust-lang.org/stable/book/ ) or the interactive version of the same book ( https://rust-book.cs.brown.edu ) Also, not sure how this resource classifies Rust for Rustaceans as a beginner level book.

Agreed, just starting Rust for Rustaceans (which I think is intended to be intermediate / next steps after TRPL) and eyes are glazing a bit about variance. Need to review a Crust of Rust or two, I know he's talked about this before.

Re: Becoming Rustacean: Resources to Learn Rust Programming

#30
https://tourofrust.com/ is fun. Learning rust has a weird initial learning curve dealing with the aggressive analyzer/compiler and how you have to approach your variables, but after that initial hump it is one of the coziest languages I've used. Having what was initially a bit of a nag, is now a godsend when i'm getting red-squiggles in vscode for a typo in my SQL string for a misnamed column, or a field in my template was removed and so my struct shows how it's now unused. Rust allows me to mainly only run the application to confirm things work from a business perspective.

For people starting out building stuff in rust - understand that there is a distinction of async code and libraries and can lead to confusing compiler errors if you don't realize there is a distinction. It's simple in hindsight but did cause me to waste hours barking up the wrong trees at first. Other wise just learn about `match` and Result/Option types asap, they're fundamental.

https://github.com/http-rs/tide tide is great to create an http server / routes

https://github.com/djc/askama I use this to template out HTML and it checks all my boxes, dynamic data, passing in functions, control flow.

https://github.com/launchbadge/sqlx sql interface for a variety of backend, async safe.

https://github.com/seanmonstar/reqwest http client to make requests

Rust is amazing, don't let the initial few speed bumps discourage you - building real things with rust is no more challenging today than any other modern language stack.

Post reply on HN