1
头图

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, Objective-C, Swift, Go, Kotlin in work. , and Rust. After finishing the 4-month artificial intelligence course in 2021, I was thinking about what skills I can bring to your Reactor friends. I have thought about whether it is a very cool product on our company's three clouds, or some solutions. event. 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. If 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. First of all, Rust's syntax is very similar to C++, with high speed and memory safety. Rust is a systems-level programming language.

Let's take a look at some comparisons between Rust and C/C++ about memory safety


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

In the above syntax in C/C++, you forget to release the pointer, which leads to memory leaks. This is a very basic problem, but in Rust, the scope is used to avoid the same problem.

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

It's really good for memory safety alone. There is also Rust to manage related packages through Crates, and the cycle of the entire project code from project establishment, construction to testing, to running and deployment, compared to the clutter of C/C++ development, it is really too comfortable.

What development tool Rust does use?

A good tool can improve the efficiency of development. For Rust development, I strongly recommend Visua Studio Code, which has very complete Rust support. After the three plugins of rust-analyzer, CodeLLDB and crates are installed, you can complete the development of rust very efficiently.

001.png

Another way to use Jupyter Notebook is also used in my class. Through Notebook, you can complete some related grammar learning and do some data analysis.

002.png

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

  1. Python environment installation and basic Jupyter Lab installation

Please refer to my previous documentation:

Windows installation

https://github.com/kinfey/HandsOnLab/blob/main/MLNetLab/docs/00_Install.pdf

Linux/macOS installation

https://github.com/kinfey/HandsOnLab/blob/main/MLNetLab/docs/00_Linux_WSL_MacOS_Install_Python.pdf

  1. Component installation

cargo install evcxr_jupyter
evcxr_jupyter --install

Note: There are different system configuration requirements, more can be found here https://github.com/google/evcxr/blob/main/evcxr_jupyter/README.md

Where is Rust applied

Rust has a wide range of application scenarios. Based on its own characteristics, it is often used in some low-level, back-end services, and network programming. The official also lists some main application scenarios
003.png
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 service frameworks. They are comparable to each other. My courses are mainly based on the Actix framework. Of course, you can also try the Rocket framework. The following are some introductions of the two frameworks, you can choose the framework according to the actual situation
004.png

Personally, I pay more attention to architecture. A good architecture is the beginning of a good project. To do back-end services, everyone can’t do without the familiar pattern of MVC. Combined with the knowledge of Rust packages, Actix’s back-end solutions can be structured very well. good item. It is recommended that you refer to the methods mentioned in my third lecture when building Rust backend services.

005.png

A follow-up supplement to the course

The three-week course is very short, and there's a lot more to Rust. For example, how to use the application of Dapr and Web Assbembly is also what I want to talk about. Next, I will talk to you through the way of Work Shop, so stay tuned!

Finally, these three series of courses are attached

006.png

Click to see Rust programming language - Rust basic learning
007.png
Click to see Rust programming language - Rust web programming

008.png

Click to see Rust programming language - Rust network programming & IoT programming


微软技术栈
423 声望996 粉丝

微软技术生态官方平台。予力众生,成就不凡!微软致力于用技术改变世界,助力企业实现数字化转型。