Official web sites:
- https://www.rust-lang.org/
- https://rustup.rs/
- https://github.com/rust-lang
- https://twitter.com/rustlang
- https://www.youtube.com/channel/UCaYhcUwRBNscFNUKTjgPFiA


Rust 是一个系统级编程语言,Rust 最早是由 Mozilla 工程师 Graydon Hoare(https://github.com/graydon) 于 2006 年开始开发的。后来提交给了 Mozilla ,2010年对外公布过 0.1.0 版本,最早由 Ocmal 语言编写。他形容 Rust 是一种线程安全的支持并发的实用型的编程语言,支持函数式编程与命令式编程。

Rust 是一门强调安全、性能和并发性的系统编程语言。它为了达到这几个目的,甚至没有一个垃圾收集器。这也使 Rust 能够应用到其他语言做不到的地方:嵌入到其他语言,有指定空间和时间需求的程序,写底层代码(如设备驱动程序和操作系统)。针对当前的其他编程语言,Rust 做到了没有运行时(Runtime),没有数据竞争。 Rust 也致力于实现“零成本抽象”,尽管这些抽象给人的感觉像一个高级的语言。即使是这样,Rust 仍然可以做到像一个低级的语言那样的精确控制。

在 2016 年,2017 年和 2018 年的 Stack Overflow 开发人员调查中,Rust 被评比为 “最受欢迎的编程语言” 之一。

首个 Rust 编译器 叫做 rustboot,始于 2010 年,是用 OCaml 编写的,它最终目的是被用于构建第二个由 Rust 实现的编译器 rustc,并由此开启了 Rust 自举的历程。除了基于 Rust 编写之外,rustc 还使用了 LLVM 作为后端来生成机器代码,来代替之前 rustboot 的手写 x86 代码生成器。Rust 第一次自举构建是在 2011 年 4 月 20 日。该过程总共花了一个小时。

Why is it called “Rust”?

TL;DR: Rust is named after a fungus that is robust, distributed, and parallel.

Also, calling Rust a research language is funny to me because – as its name reflects – we've tried hard to avoid incorporating new technology into it. We haven't always succeeded at failing to be novel, but we have a rule of thumb of not including any ideas in the language that are new as of the past ten years of programming language research. The field of programming language is full of old technology that hasn't been put to use in solving problems that it's exactly suited for. The goals with Rust were to avoid reinventing wheels, and see what the past had to teach us. I can't blame anyone for thinking Rust is a research language, though, since it is being developed by Mozilla Research.

核心设计原则

Rust 的核心设计原则:

- 实用性(Practicality) :它应该是一种可以在现实世界中使用的语言;
- 务实(Pragmatism):它应该是符合人性化体验,并且能与现有系统方便集成的语言;
- 内存安全性(Memory-safety) :它必须加强内存安全,不允许出现段错误和其他类似的内存访问违规操作;
- 高性能(Performance) :它必须拥有能和 C++ 比肩的性能;
- 高并发(Concurrency) :它必须为编写并发代码提供现代化的解决方案。

Foundation

https://foundation.rust-lang.org/ - Rust Foundation

Members: AWS, Google, Huawei, Microsoft, Mozilla

Rust 基金会的目的是使 Rust 维护人员可以快乐地把工作做到最好。Rust 核心团队相信最好的Rust 将由快乐者维护,将基金会的工作重点放在维护者身上,将为所有人提供更好的 Rust。

高性能

Rust 速度惊人且内存利用率极高。由于没有运行时和垃圾回收,它能够胜任对性能要求特别高的服务,可以在嵌入式设备上运行,还能轻松和其他语言集成。

可靠性

Rust 丰富的类型系统和所有权模型保证了内存安全和线程安全,让您在编译期就能够消除各种各样的错误。

生产力

Rust 拥有出色的文档、友好的编译器和清晰的错误提示信息, 还集成了一流的工具 —— 包管理器和构建工具, 智能地自动补全和类型检验的多编辑器支持, 以及自动格式化代码等等。

Pros

  • a uniform compiler from Rust developers with a built-in package builder and manager, test system and documentation generator
  • Safe memory management that helps to avoid segmentation errors
  • An ability to use abstractions, which makes manual memory control easier
  • Fix suggestions for most common compile errors, plus clear and concise pattern errors
  • Pointers could only be used in unsafe code – safe code only includes links to objects guaranteed to exist
  • Great compatibility with Mac and Unix-like systems

Cons

  • Lack of classes and succession, which makes writing object-oriented code harder
  • Very strict compiler that sometimes polices memory addresses too much

Online Install

Official site: https://rustup.rs/, install:

$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Update Rust:

$ rustup update stable


rustup mirror:

# 设置环境变量 RUSTUP_DIST_SERVER (用于更新 toolchain)
export RUSTUP_DIST_SERVER=https://mirrors.ustc.edu.cn/rust-static

# 以及 RUSTUP_UPDATE_ROOT (用于更新 rustup)
export RUSTUP_UPDATE_ROOT=https://mirrors.ustc.edu.cn/rust-static/rustup


https://lug.ustc.edu.cn/wiki/mirrors/help/rust-crates/ - ustc mirror
https://mirror.tuna.tsinghua.edu.cn/help/rustup/ - tsinghua mirror
https://rustcc.com/article?id=6baecc6f-29ed-40d2-870b-343606aa2e93 - Rust国内镜像源大全

Offline Install

Other Rust Installation Methods:

https://forge.rust-lang.org/infra/other-installation-methods.html

play.rust-lang.org

Just open https://play.rust-lang.org/ or https://play.integer32.com/

rustc

Edit file:

% vi helloworld.rs
fn main() {
    println!("Hello world!");
}

Compile:

% rustc helloworld.rs

Run:

% ./helloworld
Hello world!

cargo new

New project:

% cargo new helloworld
% cd helloworld

Edit file:

% vi src/main.rs
fn main() {
    println!("Hello world!");
}

Build:

% cargo build

Run:

% ./target/debug/helloworld
Hello world!

cargo install

Cargo install can install many tools registered on crates.io, like:

$ cargo install just

More tools: https://ruststack.org/rust-tools/

cargo check

Check a local package and all of its dependencies for errors

% cargo check

cargo clippy

Checks a package to catch common mistakes and improve your Rust code.

% cargo clippy

std - Rust

https://doc.rust-lang.org/std/

docs.rs

https://docs.rs/ - Docs.rs

See more: https://areweideyet.com/

Goto Rust Books

Rustup doc

Cargo docs:

$  cargo doc --open

Show Rust docs:

$ rustup doc [--book]
--alloc           The Rust core allocation and collections library
--book            The Rust Programming Language book
--cargo           The Cargo Book
--core            The Rust Core Library
--edition-guide   The Rust Edition Guide
--embedded-book   The Embedded Rust Book
--nomicon         The Dark Arts of Advanced and Unsafe Rust Programming
--path            Only print the path to the documentation
--proc_macro      A support library for macro authors when defining new macros
--reference       The Rust Reference
--rust-by-example A collection of runnable examples that illustrate various Rust concepts and standard libraries
--rustc           The compiler for the Rust programming language
--rustdoc         Generate documentation for Rust projects
--std             Standard library API documentation
--test            Support code for rustc's built in unit-test and micro-benchmarking framework
--unstable-book   The Unstable Book

Online Study

https://tourofrust.com/ - Tour of Rust - Hello, Rust

Other

https://rust-algo.club/ - Rust Algorithm Club
http://intorust.com/ - into_rust(): screencasts for learning Rust
https://www.hackertouch.com/ - Rust Tutorial - Learn Rust Programming Language from the Basics with Code Examples
https://github.com/developer-learning/learning-rust
https://rustcc.com/ - Rust语言中文社区索引站
https://resource.rs/ - Resource.rs - 旨在提供一站式的 Rust 学习资源
https://github.com/brson/my-rust-lists - Lightly organized personal notes about Rust

https://github.com/rust-unofficial/awesome-rust - Awesome Rust
https://github.com/rustcc/awesome-rust - Rust框架、库和资源的汇总, Rust中文社区
https://awesome-rust.com/ - Awesome Rust[GitHub]
https://github.com/rust-embedded/awesome-embedded-rust - Awesome Embedded Rust
https://github.com/PuzzledAlien/awesome-rust-cn - Awesome Rust资源列表 中文版
https://github.com/jetli/awesome-yew - Awesome Yew
https://github.com/rust-in-blockchain/awesome-blockchain-rust - Awesome Blockchain Rust
https://github.com/rust-cc/awesome-cryptography-rust - Awesome Cryptography Rust
https://github.com/ctjhoa/rust-learning - A bunch of links to blog posts, articles, videos, etc for learning Rust
https://github.com/zzy/awesome-rust-zh-cn - Rust棒棒哒!资源大全中文版
https://github.com/TaKO8Ki/awesome-rewrite-it-in-rust - A curated list of replacements for existing software written in Rust

https://crates.io/ - Crates.io
https://docs.rs/ - Docs.rs
https://lib.rs/ - Lib.rs


Goto Rust Crates

https://caniuse.rs/ - caniuse.rs | Rust feature search

https://areweideyet.com/ - Are we (I)DE yet?
https://areweasyncyet.rs/ - Are we async yet?
https://www.arewewebyet.org/ - Are we web yet?
https://www.areweguiyet.com/ - Are we GUI Yet?
https://areweaudioyet.com/ - Are We Audio Yet?
http://www.arewelearningyet.com/ - Are we learning yet?
https://arewegameyet.rs/ - Are we game yet?


https://wiki.mozilla.org/Areweyet - Areweyet

JavaScript Web 应用程序很难获得,并保持可靠的性能。JavaScript 的动态类型系统和垃圾回收暂停没有帮助。如果您不小心徘徊在 JIT 的快乐路径上,看似很小的代码更改可能导致严重的性能退化。

Rust 为程序员提供了低层控制和可靠的性能。它不受 JavaScript 的非确定性垃圾收集暂停的影响。程序员可以以间接,单态化和内存布局,去控制。

Wasm projects: https://www.arewewebyet.org/topics/webassembly/

Wasm Github groups:
- https://github.com/bytecodealliance
- https://github.com/wasmerio
- https://github.com/rustwasm


Learn more: https://wasm.cloudbook.wiki/

https://rustcc.cn/ - Rust语言中文社区
https://learnku.com/rust - Rust 技术论坛 | Rust 语言技术论坛 - 优质的 Rust 开发者学习社区

  1. TiKV
  2. Facebook(version control)
  3. Dropbox
  4. Firefox
  5. Discord
  6. Linkerd
  7. Google(fuschia)
  8. Microsoft(windows-rs)
  9. AWS(Firecracker)
  10. Huawei(C2Rust)

Official list: Production users
Thirdparty company list: https://github.com/omarabid/rust-companies

Create your *.cli.rs web site, access https://cli.rs/ [GitHub]

https://github.com/rust-secure-code - Rust Secure Code Working Group
https://github.com/rust-secure-code/cargo-supply-chain - Gather author, contributor and publisher data on crates in your dependency graph

Rust for {Ruby, Haskell, C, …} programmers
https://github.com/mre/rust-for-x