|0.1.5||Sep 12, 2023|
|0.1.4||Sep 8, 2023|
|0.1.3||Jul 4, 2023|
|0.1.1||May 27, 2023|
|0.1.0||Apr 4, 2023|
#200 in Programming languages
92 downloads per month
Used in 2 crates (via go-engine)
An alternative implementation of Golang specs, written in Rust for embedding or wrapping.
- In other words, it's just another flavor of Go.
- It's designed to work with other Rust code in the case where you want to offer the users of your library/app the ability to use a "simpler" language to call the native (Rust) code, like what Lua is for Redis/WoW, or Python for NumPy/Sublime Text.
- It's native to Rust, and your Rust project is looking for a scripting language.
- Go is nice and easy and you are familiar with it.
- To Rust programmers, it should be very well understood that compiler helps, as a strictly typed language, Goscript's type checker helps a lot compared to dynamically type languages, especially when your codebase gets larger.
- This readme update serves as an alpha release announcement.
- Almost all the language features are implemented as per the specs(pre-1.18, i.e. excluding generics).
- Part of the standard library is ported, which is not fully working.
- There are still a lot of work to be done besides libraries, like API cleanup, Documentation, and a lot more test cases.
- Overall it's considered buggy although it passes dozens of test cases.
- A beta release is expected in about a year from now.
Is this a new language?
No, this is Go by definition. You can think of it as a hybrid of Go and Python, it takes the design of Go and implements it the way Python does. So, I think it's also fair to call it a scripting language.
Why not a new language?
It's much easier to implement a language than to design one, I don't think I'm able to design a language that people would invest their time to learn. Go may be not perfect as a scripting language, but to me it works Ok.
Why not just use Python/Lua (with Rust)?
People will/do, and Goscript can be a reasonable alternative, a strong type system can be a friend not enemy of your creativity.
Is Goscript fast/slow?
I'm afraid it may be slower than you think. It's a VM based implementation without JIT, so there is an upper bound. Also, there is a tradeoff between performance and project complexity, we don't want a embedding language to be too big. For now, you can only expect a performance comparable to Python, I'm not sure how far we'll go with optimization in the long term.
Does Goscript support multi-threading/parallelization?
No, that'd hurt single-thread performance and make things a lot harder to implement. I guess that's also why Python/Lua doesn't support parallelization. But it supports concurrency exceptionally well via goroutine :). It's also possible to introduce parallelization with libraries in the future.
When can we actually use Goscirpt?
As mentioned above, I hope we can get it production ready in a year. I started this project three years ago, and I'll do my best not to abandon it.
How can I help?
- Report issues.
- Send a PR if it's a minor fix.
- If you plan to contribute complex changes, please contact me for a discussion first.
Just want to see if it does run Go code
- Make sure your Rust installation is up to date.
- Clone this repository.
- Go to goscript/engine
- Put whatever you want in temp.gos
cargo test temp -- --nocapture
- Or it should be trivial to make an executable that runs Go code following test.rs
- Your code doesn't run? sorry, you can take a look at what do run in the test folder.
- 其作用是用于其他的Rust项目，有时候你需要用一个更简单的语言封装和调用底层的Rust代码。就像Lua之于Redis/WoW，或者Python之于NumPy/Sublime Text。
为什么不直接用 Python/Lua (在Rust项目中)?
This crate is part of the Goscript project. Please refer to https://goscript.dev for more information.
async: Channel and goroutine support
btree_map: Make it use BTreeMap instead of HashMap