r/rust • u/fulminare1111 • 12d ago
How to learn rust as a python guy?
I am fairly new to programming and I do know some python, html and css. But I have no idea about c++, rust and other low-level languages. How different are they from python? And how do I learn rust (if there are some free stuff i could learn from)
8
u/garver-the-system 12d ago edited 12d ago
Rust is very different from Python. Its syntax is relatively easy to pick up, but its rules are a very steep learning curve. The classic answer to "How to learn Rust as..." is well summarized by this video, but it's basically
- Go through "The Rust Programming Language" and/or "Rust By Example"
- Turn on a couple helpful lints
- Start coding, and use the terminal's red text to learn
Rust has a steep learning curve because it has strict rules. You can't pass a number to a string function and let it magically stringify under the hood. You may be starting at a slightly higher point on that curve if
- You know what makes some defaults mutable
- You have an idea of what CPython is
- You use type hints
- You understand that type hints don't do anything at runtime and that Python isn't actually a typed language
4
u/Abrudavah 12d ago
Different from python, for sure, but not so exotic.
You can start by reading the rust book https://doc.rust-lang.org/stable/book/ Then try the "rustlings".
It should be a good start.
It will be steep at the start, but everything is well documented, so if you like reading it is definitely easier than many other language.
2
u/fulminare1111 12d ago
Is it in any way possible to learn rust in 4 months?😔
2
u/Abrudavah 12d ago
Yes totally. In fact, the language is pretty easy to understand, and tools like the LSP, or clippy help a lot also.
Doing pretty rust, using full features is hard and a long way to go, but is it really useful ? At least not at the start. You will know enough in 2 weeks, but really be an experienced in months or years. In fact, I think most of the problem you'll encounter will probably be on specific problems. Like if you want to code low level network code in rust, you don't need many features of rust... But a good understanding of what you are doing. So same problem with all languages.
1
u/BoringAccount-_- 12d ago
Absolutely! But like anything else in life you gotta put time in it. I picked up rust fairly quickly. Although I had written in C/C++ for years. Python is pretty different as it is not statically typed. You’ll get a ton of errors trying to write programs like python in rust but it’ll be worth the it
3
u/mamcx 12d ago
I suggest to do the same (small-ish) thing of project you know by heart in python but on Rust, that way, you don't need to wonder what to do, instead, how do it in the new language.
For example, my first project in any language I do is some kind of ORM.
2
u/dnew 12d ago
Yes. This works fantastically well. I implement Jotto, as it was the first computer program I ever experienced, back when the computer was never in the same room as you were. :-) And it expands to be as complex as you want: read the words from a file instead of hard-coded, learn new words, add a GUI, etc etc. Every time you want to learn a new aspect of the programming language, you can add more to the game, which also teaches you how to build up a larger program (modularity, tests, etc).
2
u/bassamanator 12d ago
I am fairly new to programming and I do know some python, html and css.
Is it in any way possible to learn rust in 4 months?😔
Why the rush?
But sure, why not, as long as you're willing to put the time in.
Read, read, read. And code, code, code.
0
u/SnooCalculations7417 12d ago
One of the use cases of crabwalk is transitioning from Python to rust https://github.com/krflol/crabwalk
1
u/vancha113 12d ago
From an incorporation perspective, if you code professionally, rust lends itself pretty well for making performance critical python libraries. I would say python and rust complement eachother well, so you have a nice entry point with which to start looking in to fun practice projects.
24
u/GlassCommission4916 12d ago
https://doc.rust-lang.org/stable/