Rhai

A small, safe, embeddable scripting language and evaluation engine for Rust.

Library
Cargo
v1.25.1
5,613stars
MIT OR Apache-2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
89/100Excellent
Development Activity100
Maintenance96
Community60
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
82/100Excellent
Architecture92
Code Quality90
Innovation88
Learning Curve58

Rhai is an embedded scripting language and evaluation engine for Rust that gives applications a safe, sandboxed, and ergonomic way to run user-supplied scripts. Its syntax borrows from JavaScript and Rust, supports dynamic typing, and integrates tightly with native Rust functions and types.

Designed to never panic the host and to defend against malicious scripts, Rhai is well suited to plugin systems, configuration-as-code, game logic, and any workload where end users need to extend behavior at runtime without recompiling. It runs everywhere Rust does, including WebAssembly and no-std targets.

What You Get

  • A complete embeddable scripting engine with a JavaScript-and-Rust-like language
  • Tight two-way integration between scripts and native Rust functions, types, getters/setters, and methods
  • A sandboxed, don’t-panic execution model with guards against stack overflow, oversized data, and runaway scripts

Common Use Cases

  • Adding user-scriptable plugins or extension points to a Rust application
  • Expressing business rules or configuration as editable scripts rather than recompiled code
  • Driving game logic, automation, or template generation at runtime

Under The Hood

Architecture The engine centers on an Engine type that parses source into an optimized AST (src/ast), then evaluates it via a tree-walking interpreter (src/eval) against a Scope of variables and constants. Native functions and packages are registered into a function registry, and the module system (src/module) supports dynamically loadable code. Optimization passes fold constants and prune dead branches before evaluation. Tech Stack Pure Rust (edition 2018, MSRV 1.66) with a deliberately small dependency set: smallvec, thin-vec, ahash, num-traits, once_cell, bitflags, and smartstring, plus optional serde, rust_decimal, and rustyline. Extensive Cargo features gate no_std, sync, decimal, and metadata builds. Code Quality Mature and heavily exercised, with a large tests/ suite, fuzz targets under fuzz/, benches, and a documented “don’t panic” guarantee. Roughly 4,700 commits from 71 contributors over nearly a decade indicate strong maintenance discipline. API Design The public API is compact and approachable: create an Engine, register functions/types, and call eval/run. Procedural-macro plugins reduce boilerplate for exposing Rust APIs, and the extensive online Book documents ergonomics thoroughly.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search