How I Learned to “Learn” Rust

Recently I plan to rewrite my small project Obweb backend in JavaScript. Previously, the backend of this project was written in Rust.

The rewrite is based on the following considerations:

  • Rust has a small audience, and even less overlaps with Obsidian’s user base
  • Rust is really inconvenient to develop web backends, although I have seen other Rust web frameworks, but they all seem to be immature
  • There are many pits in the process of using Warp, and the code looks very complicated
  • There are many ready-made libraries for JavaScript for web development
  • This project is relatively simple, performance is not sensitive, and using Nodejs will not make a big difference
  • I want to write JavaScript

With so many reasons, why write this in Rust in the first place?

This is the topic I want to talk about today, how I keep up with this niche and difficult programming language, and by the way, some of my feelings about Rust over the years.

I first paid attention to Rust in 2014, when it was still far from 1.0, and many things in Rust were finalized, but the core concept and design concept have been fixed, that is, without GC, through the compiler to ensure type and memory safety, taking into account performance and safety.

Not long after I got in touch, I tried to implement a simple scheme interpreter, so I started to write this little project rust-scm .

This kind of project with a few hundred lines is a good way to get started with a programming language, because input and output, recursion, testing, abstraction, etc. will be involved in the process.

At the time, I thought Rust was okay to use, but some parts were very complicated, such as pointers and Borrow checkers, and of course the biggest problem was that there were too few third-party libraries.

At that time, there was also an Indian programmer ckkashyap who opened a pit and used Rust to write a Unix-like operating system rustix: Unix kernel in rust . I thought it was interesting and made a few PRs. It didn’t take long for him to abandon the pit and turn to Nim, a more niche programming language, and plan to use Nim again to implement xv6 nim-xv6: Translate xv6 to nim . But we keep in touch, sometimes on gtalk. He has worked for about 20 years and likes to toss very much. Then he immigrated from India to Microsoft, and then I went to Microsoft in the following years. Recently he sent me an email saying that he has opened a new pit lispware/minilisp , let’s do it together, haha, we Polyglot Programmers are so easy to change our minds.

In the next few years, I didn’t pay much attention to Rust, and only occasionally read some official articles and the like. During this period, the domestic database company PingCap developed, and some Rust language enthusiasts appeared in China.

In the intervening years, I sometimes write simple exercises on https://exercism.org . The above programming questions are not algorithms, but some typical programming challenges, including test cases, which are very suitable for practicing the language you are learning. .

What’s even better about this site is that it has a number of enthusiasts in various languages ​​as mentors, and you can choose to have them review your code, so you can learn a language’s best practices from experienced mentors:

In the past year, I have re-focused on Rust and found that the popularity is much better than before. Many projects on Github are written in Rust (of course, I may have followed some developers before, and they continue to toss), related ecology and tools The chain has also developed. For example, the development experience of rust-analyzer plus VSCode is very good. For example, the Cargo management package is very useful. I’ve noticed that Rust is doing well in both the blockchain and WebAssembly areas.

Looking back, I found that several projects I was involved in in 2021 were related to Rust:

It can be said that I have learned Rust, I can write some small projects myself, I can contribute to medium and large projects in Rust, and I can also contribute to Rust itself, but I am not very clear about some language details. For example, I did Rust Quiz and found that I did many not come out. The fact that Rust takes a unique route makes the language itself more complex.

My learning method is to open a pit from time to time to practice, or to participate in some more active open source projects. I bought a Rust book in Chinese, but I don’t have the time or patience to read it.

For most development tasks, it is not necessary for us to know all the details of a programming language. A good way is to spend as little time as possible mastering the 80% of the day-to-day development needs, rather than spending 80% of the time mastering the less common 20%. I think for Rust, 20% includes macros, Unsafe, and some complicated things like Pointer, Pin, etc. It’s okay to look at these when you need to know them.

I saw a similar summary of how I learned to program by geekplux the other day:

Programming is just a tool. When learning a technology, you must quickly master its core part, abandon the details, and directly achieve the goal. If you encounter something you can’t do in the middle, you can just Google it . This is an efficient and fast way to learn.

The advantage of learning this way of thinking is that I learned everything very quickly afterwards, and I summed up a set of learning methods by myself. But the disadvantage is that the knowledge points are not firmly grasped, and many details need to be learned and sold. This seems to have no effect in daily programming. Just write them with Google, but the interview is very poor. After all, the interview is measured by examining the small knowledge points. Your knowledge level (I disagree with this interview method, but it is indeed the most popular now).

Learning something new is never linear, so if you watch someone give an optimal learning path, like finish a certain book, then read another one that goes deeper, then buy a class….

This route may be a reference, but don’t take it too seriously. The standards you have learned can definitely be applied. I think most books are more valuable without official documentation, and most courses are not yet more effective to learn directly from open source projects.

So I suggest that whether you are a novice or a veteran, if you want to learn a new technology, you should read the official documentation, and then do some small projects yourself. If you want to go further, do some larger projects, or participate in open source projects.

Usually, the technology is not difficult to learn, but the domain knowledge is more difficult to learn, because the relevant environment and work content are required to practice some domain knowledge.


Well, the above nonsense wrote an article. In 2022, I plan to learn JavaScript well ?

This article is reprinted from: http://catcoding.me/p/my-experience-learning-rust/
This site is for inclusion only, and the copyright belongs to the original author.

Leave a Comment