remix logo

Hacker Remix

Rhai: An embedded scripting language for Rust

31 points by airstrike 3 days ago | 13 comments

chaosprint 10 minutes ago

Here's a real-world example of using Rhai:

https://glicol.org/tour#meta1

I've embedded Rhai in Glicol to support sample-level audio synthesis, and the performance is acceptable. Real-time audio is very computationally intensive, after all.

I've tried various embedded scripting languages in Rust, but Rhai probably has the best documentation and playground.

For reference, see this survey:

https://www.boringcactus.com/2020/09/16/survey-of-rust-embed...

Recent Koto Lang also looks promising:

https://koto.dev/

oulipo 16 minutes ago

Cool! But wouldn't the way to go for scripting in a language these days to just compile to WASM and run in an embedded micro-VM? Why hasn't Rhai made this choice?

satvikpendem 25 minutes ago

When I last read about Rhai it was apparently very slow such that it was simply faster and more ergonomic writing scripts in Rust itself, has that changed?

MarceColl 21 minutes ago

Not sure when you read this, but I can tell you that two years ago it was VERY slow. I used it for a game and I had to redo it in lua some months later because it was a big bottleneck. I don't have more up to date information.

Black616Angel 22 minutes ago

What does "Passes Miri." mean? There is no link and online I only find a Malaysian city with that name.

Deukhoofd 18 minutes ago

Miri is a Rust tool with a similar function to Valgrind, it checks for undefined behavior.

https://github.com/rust-lang/miri