Special Planning Study Tips Volume Three Listen to What the Class Representatives Have to Say

Special Planning: Learning Tips (Part III): Let’s Hear What Class Representatives Have to Say #

Hello, I’m Ye Qian, the course editor.

To help you learn Rust and this column better in the new year, we’ve specially invited a few class representatives to share their personal experiences and methods of studying the column and the Rust language. We hope this will provide you with some references and inspiration.

Today is the third edition where we’re featuring class representatives sharing personal learning experiences. Without further ado, let’s dive into the shares.


@Milittle #

Hello, I’m Milittle.

I completed my master’s in 2020 and have been working on projects in C++ throughout my postgraduate studies. Currently, I’m involved in IaaS development, mainly using Python and Go as my languages. My goal this year is to tackle Rust, a tough cookie of a language. I’m very happy to be invited by the editor to share my learning experiences. Everyone’s experiences are different, as is their life, so here I want to share some personal insights based on my own experiences so far.

Why I Thought of Learning Rust #

The first time I learned about Rust was through CoolShell by “Left Ear Mouse,” where I saw a description of the language:

If you don’t have a complete understanding of Rust’s concepts, you can’t write any programs, not even a very simple piece of code. It forces programmers to understand all the concepts before they can code. On the other hand, it also shows that this language is not suitable for beginners …

When I read this sentence, I was very curious—what kind of language is this, and why does it force programmers to understand all the concepts before they can code? Aren’t programming languages invented to liberate programmers? So, I skimmed through some of the Rust Book content, but I didn’t delve much deeper then as I had just started working at the time.

Since I’ve been learning on GeekTime all year round, I later saw the course called “First Lesson on Rust” by Chen Tian, which coincided with my work schedule that allowed a bit of time each day, so I decided to get started with Rust. Every time I opened a lesson, it was a process of new knowledge emerging. Whenever I encountered unfamiliar knowledge, I would first search Google extensively, ingest what I could, and then revisit the teacher’s column. This approach helps me to deepen my understanding of the knowledge.

Learning new information can be overwhelming and it’s easy to lose interest, especially when you get stuck on difficult problems and give up after a while. I myself used two methods: consistent learning and repeated practice.

Consistent Learning #

In life, I’m someone with a wide range of interests. I learn photography, enjoy watching movies, and occasionally read books about economics. I believe the future belongs to those who learn continuously and keep preparing.

So, trust yourself. If you continue to learn today and it doesn’t free you from the difficulties of Rust, then you’re not being persistent enough. Keep at it and don’t give up. Perhaps tomorrow you’ll conquer Rust’s challenges.

Moreover, consistent learning can also be applied to those pieces of knowledge that don’t immediately reward you, stimulating your interest in learning further.

During my postgraduate studies, one of my research directions involved using machine learning vision technology for basic gait recognition. Although I didn’t continue for various reasons, I still made a small demo that you can check out on my GitHub (Gait Recognition Case). Since I’ve always been involved in vision, I’ve been interested in inference technology in computer vision. I combined Nvidia’s official TensorRT in my spare time and made some demos (TensorRT Cases).

With this habit, when learning Rust, I was constantly thinking about how to use it to do something meaningful. Coincidentally, December 2, 2021, was a palindrome day, so I thought about writing an algorithm to output all the past palindrome days. The next day, I immediately tried it with Rust and wrote the following code snippet:

use std::collections::HashMap;

fn main() {
    let mut valid_palindrome: Vec<String> = Vec::new();
    let mut month_days = HashMap::from([
        ("01", "31"),
        // ... [somewhat truncated for brevity]
    ]);

    for i in 1..=9999 {
        // ... [Code continues]
    }
    println!("{:?}", valid_palindrome);
}

// ... [Additional functions are defined here for this example]

You can try running it and you’ll be surprised to find that there are a total of 366 palindrome days from the year 0001 to the year 9999, which is quite intuitive but not something you could just come up with if you hadn’t written or thought about it before. This is just a simple example, but when you keep up the momentum of continuous learning, you’ll discover many more interesting things.

These are just a few small demos, but they drive me to keep learning and improving. Now, my GitHub contains many examples I’ve written. Although not every demo may bring significant returns, they have helped me maintain my enthusiasm and pleasure throughout the learning process.

Repeated Practice #

Consistent learning is a long-term process, but when faced with individual challenging knowledge points, it comes down to repeated practice.

Repetition is the ultimate learning tool for everyone. This insight comes from my high school teacher who said if you can’t learn something, just repeat it many times. If you can’t do it once, try twice; if not twice, then four times. By reviewing the material multiple times, you will definitely understand it. Of course, not all knowledge can be understood or acquired through repeated practice, but I believe that most can be mastered through it.

Studying Rust, repeated practice is what I did the most. For example, after reading the Rust Book, I’d go back to the teacher’s column, then find courses on Bilibili to reinforce and learn from other people’s views and approaches. Take my learning of asynchronous programming, for example; it was repeated practice that allowed me to understand it more deeply.

Here is a piece of code from the small Rust asynchronous booklet, which I modified slightly:

// ... [Async functions are defined here]
// ... [Output from running main function included]

Through repeated coding and thinking about the code, I concluded some points that were easier for me to understand:

  • The async keyword turns a function block or code block into a Future, which represents the steps that this block of code wants to run.
  • When we want to run a Future, we need to use the await keyword, which causes the compiler to loop at this code point and run that Future.
  • Inside the Future object, there is a poll method that checks whether the Future’s state machine is Ready. If it’s not Ready, it’s Pending; if it’s Ready, it returns the result. If it’s Pending, _task_context will yield and hand over the thread of the Future, letting other Futures continue to run on it.
  • Because the underlying object of Future is composed of Generators, when the poll method is called, it is actually calling the resume method of the generator, which returns the state machine (Yielded, Completed) to poll. If it’s Yielded, poll returns Pending; otherwise, if it’s Completed, it returns Ready. When Ready is returned, the loop is exited, and the Future will not be executed again.

These are some of the knowledge points I discovered by exploring and inspecting the code expanded by the compiler after repeated attempts. Here’s hoping this gives you some inspiration to learn Rust:

// ... [Expanded hir for learn_song] ...

Indeed, in the process of learning new knowledge, no one can fully understand a concept on the first try; it is through repetition of previous knowledge combined with personal thought that one continues to absorb and internalize knowledge. By repeatedly “leveling up,” we will eventually come to our own unique insights.

Learning Resources #

Lastly, I’ve compiled some resources that I used for learning that might benefit you:

Final Words #

Your learning methods might differ from mine, but since you’ve chosen this course, don’t regret it. Maintain the original intent of learning Rust, and with a mindset of continuing education, be determined to learn through repetition to conquer the first lessons of Rust programming. Don’t complain, don’t regret, and forge ahead boldly. You can do it.


That’s all from class representative Milittle today. If you have your own Rust learning story, feel free to share it in the comments below.

I wish you a Happy New Year, good health, and progress in your studies~