Rust Tutorial
Rust is a high-performance, reliable general-purpose programming language. Its efficiency is not only limited to development speed; its execution speed is also commendable, making it a rare language that balances both development and execution efficiency.
Rust was developed by Mozilla and was first released in September 2014. The Rust compiler is a free open-source software under the dual licensing of the MIT License and Apache License 2.0. As of January 2020, the latest compiler version is 1.41.0.
Rust official online tools: https://play.rust-lang.org/
The content of the Rust series articles is collected and organized by Sobin.
Features of Rust
High Performance - Rust is incredibly fast and has efficient memory utilization. It has no runtime or garbage collection, making it suitable for performance-critical services, running on embedded devices, and easily integrating with other languages.
Reliability - Rust's rich type system and ownership model ensure memory safety and thread safety, allowing you to eliminate various errors at compile time.
Productivity - Rust offers excellent documentation, a friendly compiler with clear error messages, and top-notch tools—package manager, build tools, intelligent autocompletion and type checking support for multiple editors, and automatic code formatting.
Applications of Rust
Rust can be used for developing:
Traditional Command Line Programs - The Rust compiler can directly generate target executable programs without any interpreter.
Web Applications - Rust can be compiled into WebAssembly, an efficient alternative to JavaScript.
Network Servers - Rust achieves security and efficiency with minimal resource consumption and strong capabilities for large-scale concurrent processing, making it ideal for developing general or extreme server programs.
Embedded Devices - Rust combines the efficient development syntax of JavaScript with the execution efficiency of C, supporting development for low-level platforms.
Who Should Read This Tutorial?
This tutorial assumes that readers already have a basic understanding of programming. Therefore, if you read this tutorial, you should have some familiarity with basic programming concepts (preferably having some knowledge of C/C++ or JavaScript).
First Rust Program
Rust language code files have the extension .rs
, such as tutorialpro.rs.
Example: tutorialpro.rs File
fn main() {
println!("Hello World!");
}
Compile the tutorialpro.rs file using the rustc
command:
$ rustc tutorialpro.rs # Compile tutorialpro.rs file
After compilation, the tutorialpro executable file is generated:
$ ./tutorialpro # Execute tutorialpro
Hello World!
Reference Links
Rust Official Website: https://www.rust-lang.org/zh-CN
Rust Official Documentation: https://doc.rust-lang.org/
Rust Play: https://play.rust-lang.org/
Visual Studio Code: https://code.visualstudio.com/