头图

There are many modern programming languages. In my programming learning, there are LOGO in primary school, Pascal in middle school, C/C++, Java, .NET in college, and Objective-C, Swift, Go, Kotlin in work, and Rust. In 2021, after the 4-month artificial intelligence course, I was wondering what skills I can bring to all Reactor friends. I have thought about whether it is a very cool product on our company's three clouds, or the practice of some solutions. After weighing it up, I decided to bring you Rust as a fresh start in 2022.

Why choose Rust?

I don't know since when, every language is born talking about its own high performance, reliability and productivity. And when you really get into the pit, there will always be all kinds of complaints. I understand that Rust was introduced by Mr. Yi Mingzhi 3 years ago. I forgot how he was Amway, but I stepped into this pit.

Rust's syntax is very similar to C++, with high speed and memory safety. Rust is a system-level programming language.
Let's take a look at some comparisons between Rust and C/C++ on memory safety:

int checkStr()
 {
char *str = strdup("Hello Reactor!"); 
return 0;                            
 }

In C/C++, the above syntax forgets to free the pointer, which leads to a memory leak, which is a very basic problem. But in Rust, we can avoid the same problem with scope.

fn checkStr(){
     let str = String::from("Hello Reactor!");
}  

Rust is good enough for memory safety alone. In addition, Rust can also manage related packages through Crates. The whole project code cycle from project establishment, construction to testing, to running and deployment, compared to the clutter in C/C++ development, is really comfortable.

What tools are used to develop Rust?

A good tool can improve the efficiency of development. For Rust I still highly recommend Visua Studio Code. There is very complete Rust support in it. Just install the three plugins rust-analyzer, CodeLLDB and crates, and you can complete Rust development very efficiently.

I also use another method in my class - Jupyter Notebook. Through Notebook, you can complete some related grammar learning and do some data analysis.

After class, some friends asked me how to install it. Here I attach the installation steps.

Python environment installation and basic Jupyter Lab installation

Please refer to my previous documentation

Windows install

Linux/macOS install

component install

cargo install evcxr_jupyter
evcxr_jupyter –install

Note: There are different system requirements, please refer to: https://github.com/google/evcxr/blob/main/evcxr_jupyter/README.md

Applications of Rust

Rust has a wide range of application scenarios. Based on its own characteristics, it is often used for some underlying, back-end services, and network programming. The official also lists some main application scenarios:

In this series of courses, I mainly introduced the work of the web backend, and of course also mentioned WebAssembly. I suggest that you can go back to the second and third lectures of my Rust course.

Rust's web framework

Both Actix and Rocket are very mature Rust page serving frameworks, and they are on a par. My course is mainly based on the Actix framework, of course you can also try the Rocket framework.
The following is the introduction of the two frameworks, which can be selected according to the actual situation.

I personally pay more attention to architecture, and a good architecture is the beginning of a good project. Back-end services are inseparable from the familiar pattern of MVC. Combined with the knowledge of Rust packages, we can use Actix's back-end solutions to build a very good project. It is recommended that you refer to the third lecture of my Rust course when building Rust backend services.

omission of course

The three-week course is pretty short, and Rust touches a lot more. For example, how to use Dapr, and the application of Web Assbembly are also what I want to talk about.
Next, I will continue to share with you through Workshop, so stay tuned!

Finally, the three lectures of this series of courses are attached:
Rust Programming Language - Rust Basics
Rust Programming Language - Rust Web Programming
Rust Programming Language - Rust Network Programming & IoT Programming


MicrosoftReactor
109 声望20 粉丝

微软 Reactor 是微软为构建开发者社区而提供的一个社区空间,以“予力多元化社区建设,帮助每一个开发者成就不凡”为使命,旨在通过不定期举办的技术讲座、开发者交流会面及技术沙龙和专题活动,帮助开发者和初创企...