7 ms·
Anyone has suggestions on learning rust for a python programmer who is also not strong on systems concepts?
by nafizh 9y ago
Anyone has suggestions on learning rust for a python programmer who is also not strong on systems concepts?
- aaron-lebo 9y agoRead the rust book and actually build something with it. There's a lot of stuff in Rust that you just never have to consider in Python so there's no easy way other than diving in. Actually, Programming Rust might be better, but it's not free. https://doc.rust-lang.org/book/second-edition/ https://doc.rust-lang.org/book/second-edition/ http://shop.oreilly.com/product/0636920040385.do http://shop.oreilly.com/product/0636920040385.do
- z0ltan 9y agoUpvoted for Jim Blandy's book. That man can teach!
- red75prime 9y agoRead the books, write code. When you'll encounter lifetimes, it's good to remember that lifetime annotations are descriptive and not prescriptive. You can't change lifetime of a variable by adding lifetime annotations. For example, local variables of a function get destroyed on function exit no matter what and you can't prevent it by adding lifetime annotation to a local variable reference you are trying to return. That was a stumbling block for me.
- littlestymaar 9y agoYou summarized it so well ! It was also a huge source of confusion for me in the beginning. Would you mind if I made a pull request to the Rust book adding your explaination to the lifetime chapter ?
- red75prime 9y agoI wouldn't. Feel free to use it. But I have the impression that the Rust book contains something to that effect. "Descriptive and not prescriptive" part probably comes from stackoverflow. I don't remember exactly.
- steveklabnik 9y agoI'm not sure where I heard it, but I certainly repeat it. It's not literally in the book though, I'll also reply to your parent about this.
- steveklabnik 9y agoWhile it doesn't have this literal text, it already does have the equivalent: https://doc.rust-lang.org/book/second-edition/ch10-03-lifetime-syntax.html#lifetime-annotation-syntax https://doc.rust-lang.org/book/second-edition/ch10-03-lifeti... > Lifetime annotations don’t change how long any of the references involved live. In the same way that functions can accept any type when the signature specifies a generic type parameter, functions can accept references with any lifetime when the signature specifies a generic lifetime parameter. What lifetime annotations do is relate the lifetimes of multiple references to each other.
- littlestymaar 9y agoCool. I haven't read the second version of the book, and I read the first version about two years ago I think. Glad to see this difficulty is now covered. Carry on with the great job Steve :)
- steveklabnik 9y agoAh ha! Yeah, it's quite different. Thanks :)
- terminalcommand 9y agoFor a python programmer some parts of Rust might feel too low-level and out of reach. However that is not a big issue. I would suggest you get comfortable tooling first, intellij rust plugin was awesome when I last checked it out. It comes with autocomplete, on-the-fly syntax checking etc. out of the box. The Rust compiler has very sane and understandable error messages (at least for basic tasks) so that will guide you a lot. I would also advise you to get on #rust-beginners on irc.mozilla.org, if you have any questions you will get instant help, which is a huge benefit :). Lastly, I would first advise you to work through https://learnxinyminutes.com/docs/rust/ https://learnxinyminutes.com/docs/rust/ to get a feel of the language (like dipping your toes into the water). If you like what you see, then continue from the Rust book: https://doc.rust-lang.org/book/second-edition/ https://doc.rust-lang.org/book/second-edition/ . And most importantly remember to have fun!
- StreamBright 9y agoDepends what is your goal. Learning a language with decent type system? Learning a language with lower level access to operating system features? I would suggest to learn OCaml because it got really popular in 2017 thanks to Facebook & Bloomberg, it has an amazing type system and you can use it to build CLI tools and web pages (Reason/Bucklescript) with an insanely good tooling (utop, jbuilder, merlin) and the community is probably the best community of software engineers I have encountered recently. If you are interested in lower level coding there is Mirage as well. https://discuss.ocaml.org/ https://discuss.ocaml.org/
- papaf 9y agoI used OCaml a few years ago and I thought it was an excellent language. Despite being powerful it was really easy to learn. One thing that put me off in the end was that it didn't support native OS threads (I have the same problem with Racket). Has threading support improved over the years?
- grayrest 9y ago> Has threading support improved over the years? The main push in this area is Multicore OCaml[1]. I don't track OCaml closely enough to know how getting this into the main compiler is going. [1] https://github.com/ocamllabs/ocaml-multicore/wiki https://github.com/ocamllabs/ocaml-multicore/wiki
- StreamBright 9y agoI am not sure what exactly you are missing, isn't this a native OS thread either POSIX or Win32? http://caml.inria.fr/pub/docs/manual-ocaml/libref/Thread.html http://caml.inria.fr/pub/docs/manual-ocaml/libref/Thread.htm...
- papaf 9y agoThe documentation that you linked to is not describing native OS threads. I am sure that the OCaml implementation is good for a lot of applications. However, because I am used to writing multithreaded code using pthread or std::thread, I find the standard OCaml model uncomfortable and limiting. Its mostly a matter of personal taste but this is the reason I stopped using OCaml.
- timClicks 9y agoHopefully I am not overstepping bounds by mentioning my book, but I encourage you to take a look at Rust in Action by Manning. It's written for current programmers who want to learn Rust as well as enough of the systems programming concepts that seem to sneak into Rust docs and discussion.
- Dowwie 9y agoI appreciate your hard work and sacrifice. Really looking forward to learning from your material, when it's ready.
- chucksmash 9y agoThe best thing you can do is to start! Your background sounds similar to mine. V2 of the docs are really good. I've called them my favorite piece of technical documentation somewhere on HN before. Anyway, the other comments about reading the docs and building things are correct. I'd just point out two things in addition. 1) Don't feel like you have to go write some impressive low level application just because the language is lower level - fizzbuzz works fine too. 2) Don't worry too much about whether you're strong enough on systems concepts. It's not a class you fail if you show up unprepared for; it's (presumably) play time you're engaging in to scratch your own itch. You'll make mistakes but that's not something to be avoided, it's the only way to learn.
- narimiran 9y ago> learning rust for a python programmer You might give Nim[1] a try. Coming from Python, you might find Nim's syntax (and significant whitespace) familiar. It took me (also a Python programmer) a week or so before I was able to write small programs in Nim. (Don't let "not yet v1.0" to turn you off) [1] https://nim-lang.org/ https://nim-lang.org/
- currymj 9y agoa big part of the early Rust community comes from Ruby, so Rust as an entry to systems programming is really common. Mozilla's IRC server has a #rust-beginners channel that is like, overwhelmingly helpful. Go and ask stupid questions. "The Rust Programming Language" is good: https://doc.rust-lang.org/book/second-edition/ https://doc.rust-lang.org/book/second-edition/ Knowing the difference between the stack and the heap, and having a picture of it in your head and understanding which variables go where, and what happens to the stack when calling and returning from functions, is pretty important. (Python wouldn't give you this intuition, although programming in something like Java might.) I half-assed learned to code in C++ for scientific purposes. Later I got deeper into Rust, and it's made me a better, safer C++ programmer when I run into C++ code.
- b0rsuk 9y agoI'm a Python programmer with no prior experience to systems outside university. Browse Python projects on github and find some that strike your fancy. Especially those which may run slow, like puzzle solvers, image manipulation apps, etc. Bonus points if they have few external dependencies. Rewrite them in Rust.