New to rust want to become rust dev

What is best way to start with it?

Based on my experience when I was learning Rust, I started with reading The Rust Programming Language - The Rust Programming Language

You do not need to instantly understand it all at the first try. Just read it to give you some initial understanding that you can understand

Then try to write the basic code that the book tell about in code editor directly, just like the above you do not need to understand it all 100% at first try

Then gain more deep specialized information from AI (Chat GPT and Claude are already incredible to teach you the basic of Rust). Use your curiousity to make it tell you about specific code you do not understand in deep and detail, that you can also make it to teach you using your local language. For example, you find a code like

std::thread::spawn(move || {

})

And then you can ask something like this in multiple question in single message

"What is that code does? What does std::thred::spawn mean? What is move and the use case of it? What is || { }? Explain it all in very detail using english language and a way that can be understood easily and beginner friendly"

Then when the AI give a word or code that you do not understand or have not fully understand, give it continous following question to explain each of thing that you have not understand yet. For example if give some words like "..... is a clossure" then you do not know what is clossure, just ask "what is clossure?" and continously, then pick next topic

Here is an example : https://chatgpt.com/c/68d00948-d0b4-832a-af76-0fc27ec5ca96

Based on my experience : If chatgpt thinking, click the skip thinking button because it mostly will give you more low level answer that will just make you more confused as you are in starting to learn. Or use claude, gemini with its learning gem model is also good, just try the 3 of them. You do not need to avoid AI, just use it in the correct place and way when you find it give some additional help

Then you can learn futher continously with the combination of reading doc, discusion with AI, watching youtube, and asking comunity if you get stuck

Here is some journey list based on my experience and what are common/heavily used. You can use the 3 combination I tell above to disscuss these and then do not forget to try them

  • variable declaration
  • ownership
  • move
  • how memory is automatically deleted in rust at the end of scope
  • drop
  • string, int
  • stack and heap memory
  • option
  • some
  • none
  • result
  • ok
  • error
  • if
  • match
  • for in
  • if let some and if let ok
  • immutable reference and mutable reference (reference and borrow has the same meaning)
  • how to solve immutable and mutable borrow at the same scope and double mutable borrow at the same scope
  • function with param and return value
  • .clone and its downside to know its use case
  • clossure, in javascript is arrow function
  • struct
  • pub (public)
  • trait
  • trait constructor
  • vector
  • for with iterator
  • while loop
  • hashmap
  • generic
  • std::thread and join handle
  • what is data race, what are example problems caused by data race, what are data race code example
  • std::sync::Arc
  • std::sync::Mutex
  • std::rc::Rc
  • std::cell::RefCell
  • Box
  • std::sync::RwLock
  • global static and const
  • lifetime, what does it mean, why it is needed, what is the use case, what happen when there is no lifetime, including how to use lifetime and what does &'static mean. My tips that may help is give lifetime declaration with descriptive name, like
fn task<'name_lifetime>(name: &'name_lifetime str)

It may help you understand quicker by the descriptive name, oh that is lifetime declaration of variable name. Overtime after you understand it clearly, you can shorthand it to &'name to still give info the lifetime is tied with which variable but with shorter name since you already know syntax ' is lifetime

  • async fn and await
  • blocking and non blocking, what is blocking and non blocking, what is the example code, what is the effect of it, what is the effect of mixing blocking and non blocking code in the same scope
  • tokio::task::spawn(async move || { }) and the join handle
  • async version of mutex and rwlock
  • std channel and async channel

Decide a simple project that you want to use as experimenting with the code of the above list little by little, or if you have project A in your previous language, try to recreate it in Rust as your medium to experiment with code

After you learned the basic code, you can continue to explore other things like

  • lock free data structure library
  • hybrid stack - heap data structure library
  • std::sync::Atomic
  • unsafe raw pointer, what thing need to be carefull with when using raw pointer, what are the pitfalls when using raw pointer

Or the very short version: you become good at Rust the same way as anything else: doing it a lot, and trying to become better.

The simplest way to do that: Find something you think is interesting but small and simple, rinse and repeat. Personally I find implementing existing protocols really handy, reading a file format like .tar, or HTTP, for example, since it gives you immediate feedback on if you're doing it right; but you might find implementing a small game or maybe something in hardware more engaging.

There's some Rust specific pointers that can make that easier, but honestly until you've bashed your head against a few brick walls it's hard to really appreciate a door. Feel free to ask if you have anything specific that seems like it's harder that you feel it should be!

4 Likes

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.