Live data from Hacker News

Exercises to Learn Rust

rust-exercises.com

61–70 of 129 posts

Re: Exercises to Learn Rust

#61
post #12

I maintain a list of Rust tips and tricks for people who are looking to dig a bit deeper: https://geeklaunch.io/blog/rust-pro-tips-collection/

Something like this in "This week in Rust" would be fantastic

Re: Exercises to Learn Rust

#62
post #59

One observation I have with Rust, looking at the code in wild, abstractions are usually (always?) leaky - implementation details are exposed/imposed due to the ownership feature of the language.

Could you give an example?

Re: Exercises to Learn Rust

#63

Wonder if there's anyone who (1) is reasonably comfortable in some popular programming language(s) and (2) has gone through these exercises could/would share their take on how helpful/useful these are? Context: I've been doing Java professionally for 10+ years, Python, JS a few years ago, C++ way earlier in my career (early 2000s).

I went through zigling variant i did about 90 of the 110 plus after reading the documentation of zig, it helped solidify some of the syntax and concepts. I think it does help reduce what might have been a 3 week process to a 1 week process during the evening learning.

Re: Exercises to Learn Rust

#64
post #59

One observation I have with Rust, looking at the code in wild, abstractions are usually (always?) leaky - implementation details are exposed/imposed due to the ownership feature of the language.

Ownership is not implementation. Ownership is contract. If you’re an owner of a house you can do more than if you’re only renting and if you’re renting you can do more than if you’re only looking at the house from the street. Ownership is a very useful concept that influences interfaces in real life so why wouldn’t it in programming?

Re: Exercises to Learn Rust

#65

What do you folks normally do after learning a language like this? (Assuming you don't use it for your day job.)

Highly specific, but in my operating systems course, we wrote a shell in C, it was very fun. I plan to write it again, but in Rust (mostly out of fun), extend it, make it my daily driver.

Re: Exercises to Learn Rust

#66
post #12

I maintain a list of Rust tips and tricks for people who are looking to dig a bit deeper: https://geeklaunch.io/blog/rust-pro-tips-collection/

Cool list! I learned a lot of new things, kudos.

One suggestion: where you talk about using AsRef, might be worth suggesting IntoIter, where it makes sense? IIRC that's what std uses for functions that aim at being generic over data structures and iterators (I might be remembering wrong, though).

In any case let's not digress from the truth: amazing list.

Re: Exercises to Learn Rust

#67
post #37

This looks like a great resource! https://rust-exercises.com/03_ticket_v1/07_setters This shows why I wouldn't use Rust for anything. Seems like a lot of verbosity for gains that don't really apply whatsoever for the kind of work I do (web apps and APIs). You have to remember let/mut fine, but then ownership/borrowing, and finally this `into()` thing - yuck! Like washing your face with sandpaper.

You get ridiculous performance gains with Rust a web backend. Even Microsoft is rewriting part of their C# backend to Rust on the 365 application side of things. Which is where you get to deal with the hefty ms-graph api which handles literal fucktons of data. Anyway. It is more verbose than something like Go or Python. I’m not sure it’s really so bad compared to most languages, but some of the benefits you get from…

> It is more verbose than something like Go or Python

Quite debatable. My experience is different. I have ported some tiny amount of Go code to async Rust and it turned out to be simpler and shorter. Way less boilerplate related to cleaning up the resources - in Rust it was actually zero additional code thanks to RAII and really nice channel design, while Golang needed a lot of additional stuff like waitgroups or manual defers plus more channels to communicate obvious things which in Rust are simply passed by result of a future.

Rust also feels a lot more expressive than Go with functional collection transformation chains (map, reduce, filter, grouping etc) where in Go this is loops and ifs all the way down. Rust is very close to Python in this regard.

Re: Exercises to Learn Rust

#68
post #59

One observation I have with Rust, looking at the code in wild, abstractions are usually (always?) leaky - implementation details are exposed/imposed due to the ownership feature of the language.

Without more details it sounds like what you are saying is there are constraints due to the ownership model. That is not a leaky abstraction.

You can also bypass some constraints, but need to be explicit about it.

Re: Exercises to Learn Rust

#69
post #59

One observation I have with Rust, looking at the code in wild, abstractions are usually (always?) leaky - implementation details are exposed/imposed due to the ownership feature of the language.

Ownership is not implementation. Ownership is contract. If you’re an owner of a house you can do more than if you’re only renting and if you’re renting you can do more than if you’re only looking at the house from the street. Ownership is a very useful concept that influences interfaces in real life so why wouldn’t it in programming?

This reads like the Rust equivalent of the OOP 'animal/cat/dog' intros of yore. Real world comparisons are almost never all that helpful when it comes to computing concepts.

Re: Exercises to Learn Rust

#70
post #22

Earlier quoted context omitted.

There’s a world outside of web development.

He's right, though. Languages today shouldn't force you to jump through low-level hoops if you just want to write high-level logic. Likewise, the low-level devices should be easily and ergonomically accessible. Rust is phenomenal at the latter but weak at the former.

Compared to most popular high level languages like Java or Go, Rust is seriously at the more expressive end (read: can be higher level).
Post reply on HN