What are the difficulties for beginners of rust?

Time:2021-5-7

abstractIs the rust language learning curve too steep? Beginners understand this mind map, quick start.

The popularity of rust language in the past two years is obvious to all. As a language with revolutionary significance, there are many doubts behind its brilliance. For developers who want to make a further progress in system programming language, learning rust language is not only a new attempt, but also a challenge in programming thinking.

Recently, Zhang Handong, author of the best-selling technical book “the way of rust programming”, summed up a paper“Learning path for rust beginners”Mind map, as the number one evangelist of rust language, Zhang Handong has participated in the management and operation of rust community in China. He has been exporting high-quality learning tutorials in major knowledge platforms for a long time, which can be said to be the first choice of enlightenment tutor for the introduction of rust language.

Based on Mr. Zhang’s mind map, we have disassembled some of its branches in detail, which may be helpful for beginners of rust language and slightly reduce the steepness of the learning curve.

First of all, no matter what kind of beginners need to know is some peripheral knowledge of rust language, including:

1. What is rust like

2. The application scope of rust language

3. Rust language community

Then, according to the different characteristics of developers, the paper puts forward some learning suggestions

1. Have the foundation of C language

2. C + + foundation

3. Java / Python / RUBY Foundation

4. Go Foundation

5. Haskell Foundation

What is rust like

Rush was originally a private project of Graydon Hoare, an employee of Mozilla. To put it more simply, it was Hoare’s personal business hobby. Who knows that he didn’t want to get involved, but in the end, it became a popular programming language.

When Mozilla learned about the project, it began to sponsor the project, and first revealed the existence of rust in 2010. In the same year, the source code of its compiler was transferred from the original Ocaml language to the rust language for bootstrapping work, called rustc, and was completed in 2011. This self compiling compiler uses llvm as its back end.

Rust is most praised by the outside world for its stability and security, and this super stability comes from its unique memory security management.

In C / C + +, many developers will encounter memory problems. Rust’s strict compiler and good design make it avoid these problems, so that it will not have memory security problems. Java and C # are popular because they eliminate errors related to memory security. However, these two languages (such as Java virtual machine and. Net) use garbage collection at runtime, which leads to running overhead and affects the performance of applications.

Rust is a static programming language without garbage collection mechanism and runtime. It realizes automatic memory collection through the newly added features of lifetime and ownership, and avoids problems such as memory leakage or hover pointer without runtime.

The characteristics of rust determine that it is suitable for developers who pursue the speed and stability of programming languages. In the official guidance document, the mission of rust is described as follows:Its most important goal is to eliminate the trade-offs that programmers have had to make for decades: safety and productivity, speed and ergonomics.

In short, rust is a direct competitor to C and C + +, and to a lesser extent competes with Java and C + +. As for whether rust can shoot the front wave on the beach, I’m afraid it will have to extend the front line to evaluate the long-term application effect.

What application areas is rust suitable for

Like C, rust is also a system level language. Moreover, since rust does not need to do garbage collection at run time, it can provide run-time performance similar to C and C + +.

Ryan levitk, chief Yunkai publisher of Microsoft MSRC (Microsoft Security Response Center), once said publicly:Rust is suitable for systematic programming,About 70% of Microsoft’s security problems are memory security. If the software is written in rust, then the 70% security problems probably do not exist.

There are many predictions in the industry that rust may become the development language of the next generation of operating system. Before that, fox used it to write a UNIX like operating system called redox. Microsoft also has plans to gradually transfer from C / C + + to rust to build its infrastructure software.

In the current field of cloud computing, rust can also be like a duck to water.

In cloud computing, it is necessary to build high-performance infrastructure components to reduce the critical overhead. For example, we have a virtual machine manager, which acts like a virtual machine manager, allowing multiple tenants to share a single physical instance of cloud resources. Rust focuses on security without affecting speed and performance.

Start ups and Internet companies can use rust to write various tasks, such as command-line tools, web projects, Devops tools, embedded devices, bioinformatics, search engines, Internet of things programs, and even the current machine learning projects.

For example, linkerd service grid proxy is built in rust.

Qovery engine written in rust is an open source code abstraction layer library, which can easily deploy applications on cloud providers in just a few minutes.

Dropbox uses rust to rewrite some of its core systems, while Mozilla uses rust to build the Firefox browser engine.

In addition, some developers develop blockchain systems based on rust. For more cases of using rust in projects, please refer to this pagehttps://prev.Rust-lang.org/zh…

Rust language community

After the emergence of a language, framework or library, people use them not only because of its own strength, but also because of the ecosystem behind it.

Community is the key carrier of cultivating language ecology, and its prosperity is another aspect of language popularity.

If you want to quickly start a programming language, the corresponding open source home page and community are the best teachers, with complete code, official guidance documents and rich supporting resources. Any problems, rust language community will have colleagues to answer in time, we promote each other, in a good atmosphere to exchange learning rust.

Straighten out learning attitude

After understanding the basic peripheral knowledge of rust language, we should have a correct learning attitude to guard against arrogance and impatience, and be able to sit on the bench.

First of all, rust’s learning curve is relatively steep, and the entry threshold is relatively high, so don’t be in a hurry for success.

Secondly, first understand the concept of rust language, and then practice. Only by understanding the basic concept and laying a good foundation can we build a good house.

Finally, remember that the compiler is your teacher. The crux of rust is its strict compiler. The compiler will do as many checks as possible to find problems during the compilation period and eliminate security risks. So the compiler is like a good teacher, killing your bug as soon as possible, forcing you to write the correct code that can run normally.

Difficulties for different types of beginners to break through in learning rust

On this basis, let’s look at the difficulties in learning rust. Here, the beginners are divided into five categories to discuss.

Zero base developerObjective: to master the knowledge structure of basic computer architecture, understand the abstraction of rust language and hardware / OS layer, understand the core concepts of rust language and its abstract mode, select a suitable field of rust language for practical training, improve the proficiency and understanding depth of rust language through practice, and master domain knowledge at the same time.

Have the foundation of C languageC language developers don’t understand the abstraction of high-level language very well, so they focus on understanding and mastering the rust ownership mechanism, including the semantics of ownership, life cycle and borrowing check. Understand the abstract patterns of rust language, mainly types and traits; As well as rust’s own OOP and functional language features.

C + + foundationC + + developers have a good understanding of the ownership of the rust language, and focus on the abstract patterns and functional language features of rust.

Java / Python / RUBY Foundation: focus on understanding and conquering rust ownership mechanism, abstract pattern, functional programming language features.

Go FoundationGo language developers can easily understand the type of rust and the abstract pattern of trait, but go is also a GC language, so ownership mechanism and functional language features are their learning focuses.

Haskell Foundation: Haskell developers have a good understanding of the functional features of rust language, and mainly attack the ownership mechanism and OOP language features.

Therefore, for developers with a certain foundation, several key concepts to master in learning rust are as follows:

1. Rust ownership mechanism, including ownership semantics, life cycle and borrowing check

Ownership mechanism is the core feature of rust language, which ensures the memory security without garbage collection mechanism. Therefore, for developers who are used to GC, understanding the ownership of rust is the most important part

  • Each value in rust has a variable called its owner.
  • Value has one and only one owner.
  • When the owner (variable) leaves the scope, the value is discarded.

It also involves the concepts of life cycle and borrowing inspection, which is relatively difficult to chew.

2. The abstract pattern of rust language is mainly type and trait

Trait draws lessons from the typeclass in Haskell. It is an abstraction of type behavior, which can be easily compared to interfaces in other programming languages. It tells the compiler what functional language features a type must provide. The consistency should be followed when using, and conflicting implementations cannot be defined.

3. OOP language features

Familiar with the four common features of object-oriented programming (OOP): object, encapsulation, inheritance and polymorphism, you can better understand some features of rust, such as impl, pub, trait and so on.

4. Functional language features

The design of rust language is deeply influenced by functional programming. People who are not good at mathematics may be deterred when they see the characteristics of functional programming, because the biggest feature of functional programming language is to write the operation process as a series of nested function calls as far as possible. In rust, mastering closures and iterators is an important part of writing high-performance rust code with functional language style.

The specific meaning and code description will not be repeated, you can refer to “rust idiom design language” and “rust programming”. In order to make you understand the concepts related to rust more easily, we hereby attach the rust materials learned and summarized by Huawei cloud experts from their own business experience. Click to download.

Finally, I would like to thank Mr. Zhang Handong for his mind map learning framework, so that beginners can systematically understand rust and approach this rising star.

Book download:  Rust language learning summary.pdf 1.96MB

What are the difficulties for beginners of rust?

Click follow to learn about Huawei’s new cloud technology for the first time~

Recommended Today

Looking for frustration 1.0

I believe you have a basic understanding of trust in yesterday’s article. Today we will give a complete introduction to trust. Why choose rust It’s a language that gives everyone the ability to build reliable and efficient software. You can’t write unsafe code here (unsafe block is not in the scope of discussion). Most of […]