Rust 開源:24 個絕佳框架、項目及資料庫

爲了方便閱讀,本文采用中英文對照的方式,英文顏色淺一些。

Rust has a very lively and fast-paced open source ecosystem, with a ton of contributors working on a ton of awesome projects.

Rust 擁有一個無比活躍且快節奏的開源生態系統,海量貢獻者在這個系統中開展海量優質項目。

And if you are asking – what can I build in Rust? The answer is almost everything.

而如果你還感到困惑:我能借助 Rust 打造什麼呢?答案是:它幾乎無所不能。

This article will feature some of the open-source Rust libraries, frameworks, and repositories that could be useful to study or use for your own project.

本文將對一些開源 Rust 資料庫、框架及儲存庫進行介紹,它們值得研究,而且或許還能直接運用到你的項目中去。

For your convenience, I’ve split them into fields such as web development, game development, blockchain, and others. Let’s dig in!

爲了方便起見,我將分領域進行介紹,分別涵蓋網頁開發、遊戲開發、區塊鏈和其他領域。咱們開動吧!

Web development frameworks for Rust

Rust 網站開發框架

Can you build a web app with Rust? Definitely!

你能用 Rust 建設一個網站應用嗎?當然能!

Rust has multiple extremely fast web frameworks – Rocket, Actix Web, and Yew – and you can use the one that matches your needs and preferences.

Rust 擁有多個極其快速的 web 框架——Rocket、Actix Web 以及 Yew——你可以根據自己的需求和偏好自行選擇。

Rocket

Rocket is the most accessible web framework in the Rust ecosystem for beginners. It is highly customizable and helps you kickstart a new application quickly. At the same time, it avoids a lot of unnecessary boilerplate. Rocket also has many features included, which means that you won’t need to go far from the framework to build everything you need.

Rocket 是 Rust 生態系統中最適合初學者使用的 web 框架。它的可定製程度很高,能夠幫助你快速啓動一個新的應用程序。同時,它也規避了許多不必要的樣板文件。Rocket 還有許多功能,這意味着,在構建你需要的一切的時候,你都無需遠離這個框架。

In contrast to Actix Web, the framework runs on nightly Rust – the “experimental” version of the language.

與 Actix Web 相比,該框架在所謂的 nightly Rust 上運行——這是該語言的 “實驗” 版本。

Actix Web

Actix Web is usually thought to be more performant and stable than Rocket. Underneath, it works with the actor model used in Erlang and Akka.

人們通常認爲 Actix Web 比 Rocket 性能更好、更加穩定。在底層,它與 Erlang 和 Akka 中使用的 actor 模型一同工作。

In contrast to Rocket, it’s less “batteries included”, meaning that you will most likely need to use third-party libraries for extra functionality.

與 Rocket 相比,它的 “內置組件” 更少,這意味着你很可能需要使用第三方資料庫來實現額外的功能。

Yew

Yew is a Rust framework for creating web apps with WebAssembly. Among its main benefits, it lists a component-based framework like in React and Elm, outstanding performance because of the multi-thread support, and JavaScript interoperability.

Yew 是一個 Rust 框架,用於通過 WebAssembly 創建 web 應用。它的主要優點是,它列出了一個基於組件的框架——這和 React 與 Elm 是一樣的;由於多線程支持,它具有出色的性能;以及 JavaScript 的互操作性。

As of now, it is not production-ready but should be an excellent choice for side projects and internal tooling, especially if you want to work with WASM.

到目前爲止,它還不能用於生產,但是對於編外項目和內部工具來說,它應該是一個很好的選擇——特別是如果你想使用 WASM 的話。

Zola

If you need something quick and simple to serve a static website, Zola is a fantastic tool to create fast and scalable web pages without any other dependencies or JS bloat.

如果你需要一個快速和簡單的工具服務於靜態網站,那麼 Zola 就是一個奇妙的工具,它可以幫助創建快速、可擴展網頁,沒有任何其他依賴關係或 JS 膨脹。

Warp

Warp is a web server framework written in Rust. In comparison to Rocket and Actix, it is rather slim for a web framework and will provide you only with basic functionality out of the box.

Warp 是一個用 Rust 編寫的 web 服務器框架。作爲一個 web 框架,與 Rocket 和 Actix 相比,它顯得相當精簡,只提供基本的開箱即用功能。

Game development

遊戲開發

Rust is exceptional for game development for the same reason that C++ is: it is predictably performant. Here are some of the engines you can use to build your own Rust game.

與 C++ 一樣,Rust 在遊戲開發領域也有上佳表現: 它具備讓人感到踏實的性能表現。以下介紹的是一些遊戲引擎,藉助它們,你可以創建自己的 Rust 遊戲。

Bevy

Two of the main Rust game engines are Bevy and Amethyst. Among them, Bevy is the newer and cooler one. It is a simple, data-driven engine and can essentially be called Amethyst 2.0 since it is heavily inspired by it.

Rust 的兩個主要的遊戲引擎分別是 Bevy 和 Amethyst。其中,Bevy 更新,也更酷。它是一個簡單的數據驅動的引擎,本質上可以被稱爲 Amethyst 2.0,因爲它很大程度上受到了後者的啓發。

For more info on Bevy, you can check out the Bevy book.

欲知更多關於 Bevy 的信息,你可以參看 Bevy 手冊。

Amethyst

Amethyst is the more mature one of the two and, because of that, has more features that you might need for a large-scale project and better integrations with 3rd party libraries. But, Bevy is catching up fast. If you are searching for an engine for your new project, I’d recommend looking at them both and seeing which one you like better.

二者相比較的話,Amethyst 更加成熟。正因爲如此,它擁有更多你在大型項目中可能用得着的特性,並且與第三方資料庫的集成度也更好。但是,Bevy 正在迎頭趕上。如果你正在爲你的新項目尋找引擎的話,我的建議是你把這兩個引擎都研究一下,看看自己更喜歡哪一個。

ggez

If you are searching for something simple to start off, ggez is a lightweight cross-platform game framework for making 2D games with minimal friction.

如果你找的是一個簡單的工具用於起步階段的話,ggez 是一個輕量級的跨平臺遊戲框架,可以幫助你在阻力最小的情況下開發 2D 遊戲。

If you want to read more on game development in Rust, check out Are we game yet?

如欲瞭解更多在 Rust 上開發遊戲的內容,請參看開始遊戲了嗎?

Operating systems

操作系統

Rust is an excellent alternative to C in operating system development since it offers the same level of performance while taking care of memory safety. Actually, developers are investigating the possibility of adding Rust to the Linux kernel, and Microsoft is experimenting with it as well.

Rust 在操作系統開發中是 C 語言的絕佳替代品,因爲它在保證內存安全的同時提供了相同水準的性能。實際上,開發人員正在研究將 Rust 添加到 Linux 內核的可能性,微軟也正在對此展開試驗。

Here are some open-source operating systems that are written purely in Rust:

以下是一些純粹使用 Rust 語言編寫的開源操作系統:

Redox

Redox is an operating system written in Rust that uses Rust’s innovations to build a modern microkernel.

Redox 是一個用 Rust 編寫的操作系統,藉助 Rust 的創新來構建現代微核。

intermezzOS

intermezzOS is a teaching operating system, specifically focused on introducing systems programming concepts to experienced developers from other programming areas.

intermezzOS 是一個教學操作系統,側重於向來自其他編程領域的有經驗的開發人員介紹系統編程概念。

Theseus

Theseus is a new OS written in Rust that presents a novel OS structure and claims to avoid the phenomenon of state spill, a thing that occurs when one entity’s state is permanently changed through interactions with another.

Theseus 是一個用 Rust 編寫的新操作系統,它提出了一個新的操作系統結構,並聲稱可以避免狀態溢出現象——即一個實體的狀態通過與另一個實體的交互而永久改變。

There’s quite a lot to read about – here’s a paper on the project.

這方面還有很多東西可以讀,詳情請參看這篇文章 。

GUI development

圖形用戶界面開發

While Rust isn’t well known for its capability for building captivating user interfaces, there’s still a lot of good libraries to build GUIs with.

雖然 Rust 在構建吸引人的用戶界面方面並不出名,但仍然有很多好的資料庫可以用來構建圖形用戶界面。

Druid

Druid is an experimental Rust-native UI toolkit with a focus on building simple, polished user experiences. It is data-oriented and inspired by modern frameworks such as Flutter, SwiftUI, and others.

Druid 是一個實驗性的 Rust 原生 UI 工具包,專注於構建簡單、精緻的用戶體驗。它是面向數據的,並受到了 Flutter、SwiftUI 等現代框架的啓發。

To learn more about it, you can check out the Druid book.

如欲瞭解更多,請參看 Druid 手冊。

Iced

Iced is a cross-platform GUI library with a focus on simplicity and type safety. It’s heavily inspired by Elm. While it is still experimental right now, it is an excellent option for creating GUIs right in Rust for your side project.

Iced 是一個關注簡潔性和類型安全的跨平臺圖形用戶界面庫。它很大程度上受到了 Elm 的啓發。雖然它現在還處於實驗階段,但它是在 Rust 中爲項目創建圖形用戶界面的絕佳選擇。

The Orbital Widget Toolkit

軌道部件工具包

The Orbital Widget Toolkit is a cross-platform toolkit for building scalable user interfaces with Rust. It’s focused on speed, ease of use, and cross-platform compatibility.

軌道部件工具包是一個跨平臺的工具包,用於藉助 Rust 構建可擴展用戶界面。它專注於速度、易用性和跨平臺兼容性。

Tauri

Tauri is a framework for building desktop applications for Windows, Linux, and macOS. With it, you can use any front-end framework that compiles to HTML/CSS/JS for building UIs, and Rust as the backend.

Tauri 是用於爲 Windows、Linux 和 macOS 構建桌面應用的框架。有了它,你就可以使用任何可以編譯成 HTML/CSS/JS 來構建用戶界面的前端框架,並將 Rust 作爲後端。

If you want to learn more about GUI development possibilities in Rust, here’s a big post that covers most of the libraries.

如欲瞭解更多關於在 Rust 中開發圖形用戶界面的可能性,可以參看這篇乾貨貼,裏面涵蓋了大部分資料庫。

Blockchain

區塊鏈

OpenEthereum

The main goal of OpenEthereum is to be the fastest, lightest, and most secure Ethereum client. It is developed with Rust and claims to provide core infrastructure that is essential for speedy and reliable services.

Open 以太坊 的主要目標是成爲最快、最輕、最安全的以太坊客戶端。它是用 Rust 開發的,並聲稱提供了對快速可靠服務至關重要的核心基礎設施。

Lighthouse

Lighthouse is an open-source Ethereum 2.0 client, written in Rust and maintained by Sigma Prime.

Lighthouse 是一個開源以太坊 2.0 客戶端,是用 Rust 編寫的,由 Sigma Prime 維護。

Parity Technologies: Polkadot and Substrate

奇偶校驗技術:Polkadot 和 Substrate

Parity Technologies works on building blockchain infrastructure for the decentralized web.

奇偶校驗技術致力於爲去中心化的網絡構建區塊鏈基礎設施。

Among its projects are Substrate, a modular framework for blockchain development, and Polkadot, a network of blockchains. Both of these projects heavily use Rust in their implementations.

該公司的項目包括用於區塊鏈開發的模塊化框架 Substrate 和區塊鏈網絡 Polkadot。這兩個項目的實現過程都大量藉助了 Rust 語言。

Other projects

其他項目

Here are some of the projects that don’t fit into any given category. Hope you can find something awesome in this collection of “things”. :)

以下項目不屬於任何特定類別。願你能在這些 “東西” 中找到一些很棒的東西。:)

Servo

Servo is a web engine prototype written in Rust. It’s the result of Mozilla’s work on creating a new, open-source browser engine. In 2020, Servo moved on from Mozilla to being hosted by the Linux Foundation.

Servo 是一個用 Rust 編寫的 web 引擎原型。Mozilla 致力於創建一個新的開源瀏覽器引擎,而 Servo 就是其努力的成果。2020 年,Servo 從 Mozilla 轉向 Linux 基金會託管。

Servo is supposed to be safer than the browsers written in C++ due to Rust’s memory safety guarantees that reduce the number of vulnerabilities.

Servo 被認爲比用 C++ 編寫的瀏覽器更安全,因爲 Rust 的內存安全保證能夠減少漏洞數量。

swc

swc is a superfast JavaScript/TypeScript compiler. In comparison to Babel, it has been benchmarked to increase the compilation speed at least 18 times.

swc 是一個超快的 JavaScript/TypeScript 編譯器。與 Babel 相比,它的編譯速度至少提高了 18 倍。

Ruffle

Want to run all the cool Flash games that Adobe has recently disabled support for? You can use Ruffle, a Flash player emulator written in Rust.

你想運行 Adobe 最近禁用的所有超酷的 Flash 遊戲嗎? 你可以使用 Ruffle,它是一個用 Rust 編寫的 Flash 播放模擬器。

You can try it out on ruffle.rs.

點擊 ruffle.rs 試試吧。

Lunatic

Lunatic is an experimental platform that uses WASM instances as actors to structure execution. It is heavily inspired by Erlang.

Lunatic 是一個實驗平臺,它使用 WASM 實例作爲參與者來構建執行。它很大程度上受到了 Erlang 的啓發。

It is supposed to unite the good sides of WASM and Erlang, enabling you to build actor-based systems that are both fault-tolerant and blazingly fast.

它旨在將 WASM 和 Erlang 的優點整合起來,使你能夠構建既容錯又快速的基於參與者的系統。

Starship

Starship is a fast, customizable, and intelligent prompt for those that want to make their shell cooler.

Starship 是一個快速的、可定製的智能提示符,適合那些希望自己的外殼更酷的人。

MeiliSearch

MeiliSearch is a powerful, fast, easy to use, and customizable search engine that’s also typo-tolerant. Now that’s a lot of adjectives! You can set it up for your own project instead of a custom and probably worse-performing solution.

MeiliSearch 是一個強大、快速、易於、可定製、具有容錯性的搜索引擎。這可真是一大堆形容詞啊! 你可以在項目裏用它,而不是轉投定製的,而且可能性能更差的解決方案。

Have anything to add?

還有什麼要補充的嗎?

As you can see, the ecosystem is vast, and there is a lot to explore. I certainly wasn’t able to cover everything. If you know of a project that deserves to be here, don’t be afraid to let us know on Twitter!

正如你所看到的,這個生態系統非常巨大,有很多內容可以探索。當然,我在這一無法一一詳述。如果你知道什麼值得在這裏討論的項目,請在 Twitter 上告訴我們!

If you want to learn more about Rust, I suggest going to our blog’s Rust section. Have fun!

如欲瞭解更多關於 Rust 的內容,建議訪問我們博客上的 Rust 專篇(https://serokell.io/blog/rust)。祝你開心!

原文鏈接:https://serokell.io/blog/open-source-rust

本文由 Readfog 進行 AMP 轉碼,版權歸原作者所有。
來源https://mp.weixin.qq.com/s/_e5iw8MtQ9dPJtfcdHAJJA