Tuesday, October 13, 2026

Scripting Rust? Rhai, Rune, Dyon, PyO3

 The premise you are highlighting is one of the most actively discussed topics in modern software engineering. Python won the world by being the "glue" language for C/C++, but as you noted, its 1990s-era design choices (the Global Interpreter Lock, dynamic typing, slow execution, fragmented packaging) created a massive maintenance overhead for modern codebases.

Today, Rust has largely replaced C/C++ as the modern systems language of choice. It offers unmatched memory safety and performance, but its strict compiler (specifically the borrow checker) makes it notoriously slow for rapid prototyping, UI scripting, or high-level business logic.

If a "Python-for-Rust" were created from scratch today, it would look distinctly different from 1990s Python, and several active projects are already trying to claim this exact throne.

What would a "Modern Python" look like today?

If we built a high-level scripting language today explicitly to wrap and script Rust modules, it would likely have these core characteristics:

  1. Strongly Typed with Aggressive Inference: Instead of Python's purely dynamic typing (which requires massive test suites to catch runtime typos), it would use a TypeScript-style or Rust-style type system. You wouldn't have to write out types everywhere, but the compiler would infer them and catch errors before the script runs.

  2. Data-Race Free Concurrency (No GIL): A modern language wouldn’t have a Global Interpreter Lock. It would feature native async/await and lightweight threads (like Go's goroutines or Erlang's actors) that map efficiently to multi-core processors.

  3. Rust-Like Error Handling: Instead of Python’s try/except blocks—where any function can crash unexpectedly—it would use Rust’s Option and Result types, combined with pattern matching. This forces the scripter to acknowledge that a function might fail, but with a highly ergonomic, readable syntax.

  4. Zero-Cost Interoperability: It would have a first-class Foreign Function Interface (FFI) for Rust. You would be able to import a Rust crate directly into your script, and the language would automatically understand Rust’s structs, enums, and traits without needing manual C-bindings.

  5. A "Cargo-like" Toolchain: It wouldn't rely on the chaotic pip/venv/conda ecosystem[1]. It would come with a single, unified tool (like Rust's cargo or JavaScript's deno) that handles formatting, linting, testing, and package management out of the box.


Known Efforts and Languages Filling this Niche

The software community is tackling this exact problem right now from three distinct angles:

1. Embedded "Rust-Native" Scripting Languages

There are new scripting languages built explicitly in Rust, for Rust, designed to be embedded in Rust applications. They abstract away the painful "borrow checker" while keeping the performance and safety.

  • Rhai: Often described as "the Lua of Rust"[2][3]. Rhai is a dynamic, embedded scripting language[4] that uses a syntax very similar to Rust/JavaScript but completely removes the concept of lifetimes and borrowing[5]. It is incredibly easy to expose Rust functions to Rhai scripts[6][7].

  • Rune: An embeddable dynamic language for Rust that is "async-first."[5] It natively supports modern asynchronous programming and macros, allowing developers to script high-performance async Rust backends without wrestling with Rust's strict compiler rules[8].

  • Dyon: A dynamically typed scripting language written in Rust that uses a "lifetime checker" instead of a garbage collector. It’s an experiment in making a scripting language that feels structurally like Rust but without the cognitive overhead[9].

2. Evolving Python Itself via PyO3

Ironically, the most successful "Python-for-Rust" language is simply... Python.
Because Rust is so safe and has such incredible macro capabilities, a project called PyO3 (and its build tool, Maturin) has made it completely frictionless to write Rust code and expose it to Python.
Instead of inventing a new language, the ecosystem is rapidly rewriting Python's heavy lifting in Rust. Modern Python staples like Polars (dataframes), Pydantic (data validation), and Ruff (linting) are just Rust programs cleverly wearing a Python trench coat. Rust is effectively saving Python from its own performance bottlenecks[4].

3. The "Python but Fast" Languages (Systems-Level Python)

There are active attempts to completely rebuild Python's syntax from the ground up to achieve C/Rust-level performance without needing a second language underneath:

  • Mojo: Created by Chris Lattner (the creator of LLVM and the Swift programming language), Mojo is a superset of Python. It aims to have the exact same syntax as Python but allows developers to gradually drop down to systems-level memory management and strong typing. While its current focus is AI and the C++ ecosystem, conceptually, Mojo is exactly what "Python created today" looks like.

  • Erg: A statically typed language that compiles down to Python bytecode[10]. It looks like a modern, functional Python but provides the strictness and safety guarantees of a language like Rust[10], running perfectly alongside existing Python libraries.

Summary

If Python were invented today to script Rust, it would look a lot like TypeScript mixed with Rust's error handling, running on a lightweight garbage collector or automatic reference counting, without a GIL. While projects like Rhai and Rune are attempting to be exactly this[7][9], the pragmatic reality is that tools like PyO3 have made Rust and Python such good friends that the industry is simply using them together to get the best of both worlds.

Here are the GitHub links to all the projects mentioned, categorized by how they approach the problem:

1. Embedded "Rust-Native" Scripting Languages

These are the languages built in Rust specifically to act as high-level scripting layers for Rust applications:

2. Evolving Python Itself via Rust Interop

These tools allow you to use standard Python as your scripting language while doing the heavy lifting in Rust, along with examples of massive projects doing exactly this:

Examples of "Python as a wrapper for Rust":

3. The "Python but Fast/Strict" Languages

These are the languages trying to reinvent Python's syntax for the modern, systems-level era:

  • Mojo: https://github.com/modularml/mojo
    (Chris Lattner's project to build a strict, systems-level superset of Python. The core compiler is proprietary to Modular, but the standard library and issue tracking are hosted here on GitHub).

  • Erg: https://github.com/erg-lang/erg
    (A statically typed language that compiles to Python bytecode, giving you Rust-like strictness while running alongside normal Python.)