So, I want to learn Rust. I am a C# / Python programmer, experienced. Are there any particular set of problems that I can solve systematically, so that I can learn all the features of Rust?
Rust 1.46
21–30 of 157 posts
Re: Rust 1.46
#22Earlier quoted context omitted.
> Anyways, I guess this gets easier over time, right? Yes. > Should I avoid using closures all over the place? Not necessarily. > Should my code look more like C and less like Haskell? Yes. Others sometimes don't like to hear this, but IMO, Rust is not at all functional. Passing functions around is not ergonomic (how many function types does Rust have again? Three?). Even making heavy use of Traits, especially generi…
> how many function types does Rust have again? Three? It has to, right? ATS has many function types as well, plus stack-allocated closures (I think Rust has that too??)
(and yes, there are three types of closures, because they need to know if they take said struct by reference, by mutable reference, or by owner.)
Re: Rust 1.46
#23I’m learning rust right now and there is a lot to like. Steady updates like this are also very motivating. The ecosystem feels very sane - especially compared to npm. Top notch Wasm support, cross compiling is a breeze. That said, coming from a FP background (mostly Haskell/JS, now TS) Rust is... hard. I do understand the basic rules of the borrow checker, I do conceptually understand lifetimes, but actually using th…
* If you need to keep unchanged the input, you must either use a reference-to (.iter()) or copy-of (.iter().cloned()) of each item
* If you don't need the input ever again, you should move the items (.into_iter())
These rules follow for each step of the chain.
I very very often write very Functional code in Rust and I find it natural and easier to reason about than imperative-style code. The example I could find the fastest: https://github.com/thenewwazoo/aoc2019/blob/master/src/day10...
Edit: another example (this one uses types that are Copy so the copies are implicit) https://github.com/thenewwazoo/cryptopals/blob/master/src/tr...
Another edit: I am not a Functional programmer, and have never known Haskell or any Lisp. Erlang is as close as I've ever gotten. I've found Rust to be a fantastic language for writing Functionally.
Re: Rust 1.46
#24Earlier quoted context omitted.
> Anyways, I guess this gets easier over time, right? Yes. > Should I avoid using closures all over the place? Not necessarily. > Should my code look more like C and less like Haskell? Yes. Others sometimes don't like to hear this, but IMO, Rust is not at all functional. Passing functions around is not ergonomic (how many function types does Rust have again? Three?). Even making heavy use of Traits, especially generi…
> how many function types does Rust have again? Three? It has to, right? ATS has many function types as well, plus stack-allocated closures (I think Rust has that too??)
Re: Rust 1.46
#25So, I want to learn Rust. I am a C# / Python programmer, experienced. Are there any particular set of problems that I can solve systematically, so that I can learn all the features of Rust?
https://doc.rust-lang.org/stable/rust-by-example/ is the "by example" introduction, which is all about sample programs, but feels a bit dated, IMHO. Still not incorrect, but not up-to-date.
You may also like the O'Reilly book, or Rust In Action, which use more fully-featured example programs more heavily than The Book does.
Re: Rust 1.46
#26Note that entire rust team was recently fired from Mozilla, so it is unclear how the future looks like for the language. Especially since it does not have a spec and only have single reference implementation
They're moving to a Rust Foundation with corporate sponsorship model. I think Rust will be fine, even Amazon expressed interest in sponsoring development.
System languages don't grow on trees. Rust has had a lot of non-trivial effort put into it and is very usable right now. Somebody is going to see the value just lying around and is going to pick up the financial slack.
I see it as vaguely analogous to the current movie theater situation in the US. A lot of companies are seeing the end of their business, but all of those buildings are still sitting around waiting for someone to swoop in and buy them for fire sale prices.
Re: Rust 1.46
#27These const fn’s are cool, but won’t this also lead to long compile times down the road?
Yes, any time you move computation to compile time, it makes the compile time take longer. As always it is a tradeoff. One thing that people may not realize, especially now that we have loop. You may expect this to hang the compiler: const fn forever() -> ! { loop { } } static FOO: u32 = forever(); But it won't: error[E0080]: could not evaluate static initializer --> src/lib.rs:2:5 | 2 | / loop { 3 | | 4 | | } | | ^…
That could be a real hard-to-source build stall.
Re: Rust 1.46
#28So, I want to learn Rust. I am a C# / Python programmer, experienced. Are there any particular set of problems that I can solve systematically, so that I can learn all the features of Rust?