真能折騰:用Rust實現(xiàn)一個Go腳本語言
在 GitHub 發(fā)現(xiàn)一個項目:goscript,這個項目挺有意思。它計劃實現(xiàn) Go 語言規(guī)范,同時增加一些動態(tài)語言特性,打造一個類似 Python 或 Lua 這樣的動態(tài)語言,但語法是 Go 語言的。
這個項目是使用 Rust 實現(xiàn)的,一方面希望可以像 Lua 一樣被嵌入使用,比如嵌入 Rust 中;另一方面也希望像 Python 一樣,可以單獨作為腳本語言使用。
項目地址:https://github.com/oxfeeefeee/goscript,Star 數(shù):782,去年 4 月份啟動的項目。(目測我這一推廣,Star 數(shù)增加不少,
)
目前官方提供了一種方式進行試驗:
The project "engine" is the entry/wrapper. there are test cases in here[1] to browse through.
Make sure your Rust installation is up to date. Clone this repository. Go to goscript/engine Run cargo test -- --nocapture
扒了一下,發(fā)現(xiàn)這個項目的作者是國人。如果你對這塊感興趣可以關(guān)注下!
此外,該項目還有具體應用。我們知曉,Go 官方的 Playground,Go 的編譯運行是服務(wù)端處理的。但有一個 Playground:https://go-playground-wasm.vercel.app/,它是在瀏覽器運行 Go 代碼,也就是訪問這個網(wǎng)址后,即使斷網(wǎng)了,也可以運行 Go 代碼。這個項目使用的就是 goscript 和 WASM。

文末「閱讀原文」可以直達項目首頁。
參考資料
here: https://github.com/oxfeeefeee/goscript/tree/master/engine/tests
推薦閱讀
覺得不錯,點個贊吧
掃碼關(guān)注「Rust編程指北」
