Learning Rust with no background in programming


I new to rust and th language seems to be vey daunting.

Any tips or suggestions on how I could learn to use this would be very helpful.

1 Like

Solve the exercises from Rust by Example, and then practice your newly acquired skills on solving problems that you are interest in.

I recommend the rustlings exercises .

As I have said previously on this forum, I feel like Rust is (or rather: could be) generally a suitable language to start with. However, IMHO there is a lack of good learning material for people who have absolutely no prior background in programming.

Apart from the tips in this thread, feel free to return here for particular questions. Usually people here are very patient in answering beginner's questions; so in addition to the tips above (and the book, which is also listed under getting started), I can recommend to ask questions whenever you're stuck with something.

1 Like

Most of the guidance for learning your first programming language are the same no matter what; find and work through the closest thing to a tutorial for the language you can find, this should introduce you to generic programming terminology and concepts like "comments", "variables", "strings", "indexes" and the like. Thankfully, Rust has a reasonably good set of learning material on the official site, that the others here have linked! Try whichever feels best to you, different people respond better to different styles of introductory material.

You should still expect to find this hard! Rust is absolutely a hard language in many ways, but the argument here is essentially that this is because it shows you that you are doing something hard right away, rather than it creeping up on you after you've already written a bunch of code. This might not be the best if you're just learning the language as it's distracting from what you're trying to accomplish, but the general rule of thumb is: if you're trying to make something work and it just isn't, then you're probably trying to do something you "shouldn't" be, in some sense. The most obvious example for Rust is that you shouldn't need to explicitly write any lifetime annotations (they look like 'blah, with the leading ') for a long time. Do read the compiler errors, they are very good quality and friendly in comparison to many other languages, but they don't know what you're trying to do, and their suggestions are only suggestions.

Once you've worked through enough tutorial content to get bored (importantly, you don't have to learn everything at once!), https://adventofcode.com/ is a great way to independently verify that you've actually been learning how to write programs in general: it gives you problems that are increasingly difficult, verifies that you have a correct solution at each step and builds on your previous knowledge. Getting even the first day is doing really well for a complete beginner even with assistance, so don't jump in right away!

It's heavily weighted, necessarily, to processing tasks where you read a bunch of input, think about it, then spit out a bunch of output, which isn't how the majority of programming actually works, but it will let you check if you've picked up the general ability to break down a problem as stated into the steps that are needed, figure out what's wrong, and iterate until it works, which is common to all programming. It is also remarkably good at pushing you to pick up good habits like writing tests and writing code that is easy to modify.

Every programmer googles, don't be afraid to look up even the smallest things like "how do you make a list in rust" up to general problems like "how do you write a web server in rust". Unlike a lot of languages, Rust is new and stable enough that the answers that are the most popular are actually still good. Nowadays, you can also use AI tools like ChatGPT, which actually give surprisingly good answers for reference-type programming questions like "how do you _ in Rust" - you may prefer the faster interaction than scanning through articles and reference documentation.

Regardless, you should at some point learn how to read reference documentation, you can quickly search the standard Rust library with the site std.rs, for example std.rs/split will show you all results for split, and it's handy to be able to pick the relevant result (here, probably str::split()) and understand what it's saying: in this example this will tell you that you will get empty items in between the separators, that splitting an empty string will always give you a single empty string, and other edge cases you might not have considered.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.