Rust-Notes
Introduction | 前言
当我们需要编写接近实时高性能,稳健,并有足够开发效率的大程序时,譬如数据库、交易系统、大型桌面应用等,往往会首先选择
-
不需要自动垃圾回收
(GC) ,避免因为垃圾回收导致的程序中断,以及可能引发的错误或者麻烦。 -
有成熟完善的基础组件库,以保证开发效率。这一点正是
C 的不足,其虽然能保证高性能,但却需要重复造轮子;而C++ 虽然内置了标准库,但是其却缺乏统一、完善的包管理器。 -
零开销抽象
(Zero Cost Abstraction) ,我们希望有合适的抽象来保证开发效率、可读与可维护性,但是这种抽象必须是没有运行时开销的。因此我们需要静态强类型多范式语言,编译器能够尽早地发现问题,并且在编译阶段即能自动地进行性能优化;譬如C++ 中,编译器如果发现虚类(Virtual Class) 没有真正被用到甚至会优化掉虚表(Virtual Table) 。
借鉴 How Stylo Brought Rust and Servo to Firefox 一文中的阐述,
-
They borrowed Apple’s C++ compiler backend, which lets Rust match C++ in speed without reimplementing decades of platform-specific code generation optimizations.
-
They leaned on the existing corpus of research languages, which contained droves of well-vetted ideas that nonetheless hadn’t been or couldn’t be integrated into C++.
-
They included the unsafe keyword - an escape hatch which, for an explicit section of code, allows programmers to override the safety checks and do anything they might do in C++. This allowed people to start building real things in Rust without waiting for the language to grow idiomatic support for each and every use case.
-
They built a convenient package ecosystem, allowing the out-of-the-box capabilities of Rust to grow while the core language and standard library remained small.
背景
任何一门新技术的兴起,都是为了解决一个问题。自操作系统诞生以来,系统级主流编程语言,从汇编语言到
很难编写内存安全的代码。
很难编写线程安全的代码。
这两个难题存在的本质原因是
“Rust”这个名字包含了
Nav | 关联导航
About | 关于
Contributing
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Acknowledgements
-
Awesome-Lists: 📚 Guide to Galaxy, curated, worthy and up-to-date links/reading list for ITCS-Coding/Algorithm/SoftwareArchitecture/AI. 💫
ITCS- 编程/ 算法/ 软件架构/ 人工智能等领域的文章/ 书籍/ 资料/ 项目链接精选。 -
Awesome-CS-Books
: :books: Awesome CS Books/Series(.pdf by git lfs) Warehouse for Geeks, ProgrammingLanguage, SoftwareEngineering, Web, AI, ServerSideApplication, Infrastructure, FE etc. :dizzy: 优秀计算机科学与技术领域相关的书籍归档。
Copyright & More | 延伸阅读
笔者所有文章遵循知识共享 署名
