Special Planning Learning Tips Listening to Class Representatives' Opinions

Special Planning: Learning Tips (Part 1)—Hear What the Class Representatives Have to Say #

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

The new year is almost upon us, and I’d like to wish you a Happy New Year in advance! After all, many students are probably getting ready for their first, second, third… Rust introduction after the new year. A multitude of joys is on the way.

Because the content of the column is very rich with many distinctive sections, new students are often confused about how to learn and get started more smoothly: Why do I get more confused the more I watch the first 6 lectures? What background knowledge do I need to learn Rust, to study this column? There’s been a wish for a user manual for the column, or for organizing some background knowledge…

To help you learn better in the new year, I have specially invited several class representatives to share their personal experiences and methods of learning the column and the Rust language. I hope this can give you some reference and inspiration.


@newzai #

Hello, I am newzai, and I’d like to share my Rust learning process with you on this occasion. Before learning Rust, I already had 10 years of C++ development experience and 4 years with Go.

My Learning Journey #

I began to try learning Rust in 2019. At the time, there weren’t many books available in China. I did not buy any books, but rather looked at the official English-language books. I found that the first few chapters were not much different from other programming languages. Following the official installation guide (macOS) and code, I read along and typed, encountering few obstacles.

It wasn’t until reaching ownership and lifetimes that I basically could not figure it out. After reading about traits, I could partly understand since they are somewhat similar to Go’s interfaces or C++’s abstract classes. However, I was overwhelmed by the rich functionality of traits and could not continue; I gave up briefly.

At the end of 2020, some time after my first failed attempt at learning Rust, and due to encountering performance and concurrency safety issues in Go projects, I began my second attempt at learning Rust, leveraging Chinese books and Ge Jian Time with Zhang Handong’s video course.

Mainly focusing on books, I read almost all the Chinese-language books available at the time from cover to cover 1-2 times. These included “The Rust Programming Language,” “Rust by Example,” “Mastering Rust (Second Edition)” (the first few were 2015 editions, while Mastering Rust was newer, a 2018 edition). I did not pick up “The Tao of Rust” since I had purchased Zhang Handong’s video course; I thought it seemed redundant to buy and read the same author’s material again.

By June 2021, after finishing these books, I had basically come to understand many syntactical points and knowledge but still couldn’t handle lifetimes and how to carry out project practice, especially in scenarios involving mutual references of objects in multithreading. After researching for a month or two, I still couldn’t get it clear. After all, the ultimate purpose of our language learning is to be applied to use. To use familiar business scenarios from our work and implement them in Rust is the best way to integrate the scattered knowledge acquired day by day.

As I work on the development of WebRTC SFU media servers, I have been trying to rewrite the SFU server in Rust. I had developed the company’s media server using the Go pion WebRTC library, and the pion team also happened to be rewriting the Go version of the WebRTC library in Rust, so I kept an eye on the webrtc-rs library’s beta version releases.

Eventually, around September 2021, the first 0.1.0.0 version of webrtc-rs was released. At this time, I had finished watching Zhang Handong’s video course and had been following Chen Tian’s “The First Lesson in Rust” for a while. Feeling that I had accumulated enough knowledge, I set out to write my own SFU server.

At this point, I knew quite a few third-party libraries, mainly according to “Mastering Rust (Second Edition),” Ge Jian Time with Zhang Handong’s video course, and Chen Tian’s “The First Lesson in Rust” recommendations, I mainly used libraries like tokio, anyhow, async-trait, prost, serde, axum, etc. If you want to write something in Rust yourself, you can also focus on mastering these libraries. Of course, the libs.rs website can also provide many other resources.

My Project Practice Process #

The SFU service needs to provide WS and HTTP protocol services, therefore requiring the choice of a web framework.

Initially, based on online recommendations, I chose actix-web. Since its tokio version was quite old and had issues cooperating with newer tokio libraries, I faced many initially insurmountable problems with all sorts of inexplicable errors. Finally, using the RT global approach, I bridged it myself (defining a global tokio::runtime object to call in the actix handler method; later on, I learned there’s a library called tokio-compat that does this sort of thing), and this got the process running.

After encountering axum, I switched to axum. The switch was very smooth, which I owe to Rust’s well-designed traits. Like in Chen Tian’s first lesson on the evolution of the KV service design, the costs of replacing protocols, replacing frameworks, are all very low.

Therefore, over the National Day holiday in 2021, based on previous accumulation, I took 5 days to implement a basic SFU server. It could use Janus gateway’s H5 as a client for videoconference communication. Although far behind the functional Go version running in production, this was a crucial first step, and subsequently, things became much easier.

Recently, most of the features have been completed. We’ve been doing performance benchmarking between the Rust SFU version and the Go SFU version. Overall, there’s an improvement of over 20% compared to Go, and the gap widens with higher concurrency.

Words of Encouragement #

Today, I’ve focused on sharing my own learning and application experiences with Rust. Personally, I think Rust is worth the time investment. It performs very well in terms of performance, safety, and development efficiency. Moreover, I’ve found that the more I understand Rust, the more I benefit. Of course, Rust currently has its shortcomings, especially in terms of compilation time and ecosystem, which I believe will improve over time.

No two leaves in the world are identical, just as each person has their own methods and paths of learning. I hope my experience can help you all.

A language, if only for subsistence, learn the most popular ones; if for broadening your horizons and adding to your thoughts, you might study several. Each language has its design philosophy. Understanding more can help you with your primary language, so don’t limit your thinking.

Rust is going through the development phase Go did in 2016-2017, so from this perspective, the current investment in learning Rust seems rather timely.

Finally, I suggest you fully go through the syntax and basic knowledge at least 1-2 times. If you have the habit of learning while practicing on projects like with other languages and wanting to get started with Rust directly, you might become overwhelmed.


@MILI #

Hello, I am MILI. I am delighted to have been invited by the editor to share my Rust learning experience. I am a full-stack front-end engineer who has been working for almost 5 years, doing a little bit of everything as required by work, occasionally full-stack, occasionally cutting designs. I enjoy exploring and learning independently.

How I came to know Rust began a few years ago when I was still a junior front-end developer looking to learn a new programming language to enrich my programming journey. Coming from JavaScript, a weakly-typed language, I hoped the new language would have strong typing, high performance, security, and other features.

In 2018, I learned about Rust, which at that time only had one the book document; asynchronous features were not yet there, and job positions on Boss Direct Hire were limited mostly to ByteDance and a few blockchain companies, which could be counted on half a hand. After several years of rapid development, Rust has now established a foundation and blossomed in various fields, already bearing fruit in some areas, especially front-end development, where Rust is increasingly used to improve toolchains.

How I Learnt Rust #

In the initial stages, Rust learning materials were scarce. Later, I encountered Han Dong’s books and videos. Even now I am continuing with Mr. Chen Tian’s courses. Rust learning materials online are becoming increasingly rich. Here I would like to share my process of learning Rust.

  • Reading the book—understood it in theory, not in practice;
  • Reading Han Dong’s books and videos—comprehensive, even bought the ebook later for convenience and continuous learning (the ebook was updated and revised);
  • Practicing with rustlings, the small exercises can get you used to reading and writing Rust code—tough and didn’t go well;
  • Practicing with exercism, an online programming learning website. The mentors there are fantastic and provide free programming guidance—made some progress in the basic section of the online learning site;
  • Practicing on codewars, a site similar to LeetCode—used Rust to level up to 5 KYU;
  • Building an IM system—using poem by “fried dough stick brother” and tauri, combined with Chen Tian’s “The First Lesson in Rust,” I started working on an online IM chat system. The column started to have many examples, and the code was very well written. I learned a lot from it and felt it wasn’t so hard anymore. However, due to work at the end of the year, I did not continue, but I still learned a lot;
  • Practicing on LeetCode—junior algorithms + daily challenges, assertively tackling the easy ones; persisting with medium ones, referencing three leaves’ solutions; looking up three leaves’ solutions for the difficult levels. I did the linked list problems because they help understand Rust’s ownership, borrowing, references, mutable borrowing, and I practiced repeatedly by combining them with Mr. Chen Tian’s explanations in the column.
  • Looking back, I went through rustlings again, taking less than a day, and also came up with many additional scenarios to consider.

From my learning experience, you can feel that I have been repeatedly entering Rust. As a front-end engineer, my main frustration came from types, ownership, lifetimes, and such concepts, while asynchronous programming was an advantage and easy to grasp.

In the early stages of learning Rust, you might find it very uncomfortable. You might feel that the Rust compiler is always getting in the way of compiling, producing all sorts of red errors. If you don’t read the error messages carefully, it can be very discouraging and you need to get through a difficult period of adjustment.

But once you are familiar with it, you’ll really want the compiler to give you hints to improve your work. Rust compiler will reteach you how to think about programming, focusing on memory safety, designing systems well before writing code, rather than designing while writing. So far, only Rust seems to be able to provide this experience. What we need to do is not to fight the compiler, but to understand the errors it presents and the solutions it proposes.

After the adjustment period, lots of fundamental knowledge remains to be mastered. After all, Rust is just a programming language that has to be used to create applications. How deep one should study depends on each individual’s choices.

For myself, as JS is a weakly-typed language and I don’t have a strong-typed language background, many concepts in Mr. Chen Tian’s course need some time to understand. I need to fill in this knowledge myself, rather than relying entirely on the course. However, the course has a wealth of relevant hyperlinks, making it very convenient to supplement learning.

Words of Encouragement #

I recommend getting hands-on experience, paying close attention to error messages, contemplating scenarios spawning from those errors, and seeking to understand why they happen. Make good use of tools associated with Rust’s toolchain like cargo; it is recommended to use the Dash app for querying Rust API, or the Chrome extension Rust Search Extension can also work—sometimes you can even discover new opportunities.

I look forward to progressing together with you all in the new year and wish you a Happy New Year in advance!


That’s today’s sharing from two class representative students. If you have your own Rust learning stories, feel free to share and interact in the comment section below. Let’s learn and progress together.

See you in the next edition!