Skip to content
mimas

mimas

A flexible, statically typed scripting language for Rust.

docs version built with Rust license ci tests

Get started · Tour the language · Why mimas? · Benchmarks · Reference


mimas is a statically typed, embeddable scripting language for Rust. It carries over much of Rust's syntax and ergonomics, reshaping the rest to deliver what a scripting layer is good for: fast iteration, quick compile times, and runtime flexibility -- without trading away the safety that keeps you out of the debugger.

enum Shape {
    Circle(float),
    Rect(float, float),
}

fn area(shape: Shape) -> float {
    match shape {                          // exhaustive -- miss a variant and it won't compile
        Shape::Circle(r) => r * r * std::math::PI,
        Shape::Rect(w, h) => w * h,
    }
}

let shapes = [Shape::Circle(1.0), Shape::Rect(2.0, 3.0)];
let total = 0.0;
for s in shapes { total += area(s); }
print(f"area of {shapes.len()} shapes: {total}");

What you get

🪶 Flexible Inference writes your types, compiles stay fast, and errors point toward the fix instead of just turning you away. Garbage collected -- no borrow checker, no lifetimes.
🛡️ Typed Static typing with inference, user-defined types, exhaustive pattern matching, and T? option safety so an unexpected null can't reach you.
🧩 Extendable Share Rust types and functions with the #[mimas] macro -- they're type-checked just like native ones.
✅ Robust Every panic is treated as a bug, top to bottom. Over 1,900 tests (the tests are tested, via cargo mutants), with clear diagnostics powered by miette.

Read the full tour for a quick pass over the whole language.

Quick start

At the command line -- mirroring cargo, with check, build, and run:

cargo install mimas-cli

mimas check my_script.mim   # parse + type-check
mimas run my_script.mim     # execute (or just `mimas my_script.mim`)
mimas run my_project        # runs the project's one script, with its modules
mimas my_project            # running with no subcommand defaults to `run`

Embedded in a Rust project -- add mimas and compile a script in two lines:

const SOURCE: &str = include_str!("my_script.mim");

let mut vm = mimas::compile_source(SOURCE).unwrap();
let _ = vm.run();

Sharing your own Rust types is one attribute away:

#[mimas]
struct User(String);

#[mimas]
impl User {
    fn greet(self) { println!("Hello, {}!", self.0); }
}
let user = User("mimas");
user.greet(); // -> Hello, mimas!

The full embedding guide lives at Extension with Rust.

Performance

mimas compiles .mim source to bytecode for a register-based VM with a lifetime-safe (gc-arena) heap. It outpaces the other pure Rust languages in most tests and is within shooting range of Luau, a mature C++ runtime. See the full benchmarks for the methodology and numbers.

The compiler is quick too: the whole pipeline (parse, type-check, lower, emit bytecode) runs at roughly 500,000 lines per second, so for scripts there's effectively no compile step you'd notice.

Examples

Runnable projects live in examples/:

  • extension -- sharing Rust structs, enums, methods, and fallible functions with a script via #[mimas].
  • game-loop -- driving a script from a host game loop, using fixtures and FreezeCell to safely hand mimas a &mut to host state.
  • bevy — a breakout game on the bevy feature, which runs .mim scripts as hot-reloaded Bevy assets with typed access to reflected components, resources, and messages. See the Bevy guide, and run it with cargo run --manifest-path examples/bevy/Cargo.toml.

Editor support

A language server, mimas-lsp, gives any LSP-capable editor diagnostics, hover, go to definition, references, rename, outlines, and inlay hints. Running a Rust host through cargo writes its API to target/mimas/api.json, which the server loads so scripts that use the host's types and functions are checked against them. See the Language Server page for setup and limitations.

A VS Code extension lives in tools/vscode. You can install it from the marketplace.

Status

mimas is early in development. It compiles, type-checks, and runs end-to-end, but nothing is promised to be stable yet. Expect sharp edges, expect things to move, and feel most welcome to contribute.

How it's built

A single pipeline turns source into a running program, split across a handful of crates in crates/:

.mim -> parse -> solve (type check) -> compile (lower + bytecode) -> vm (register VM)

shared carries the common vocabulary, api and macros back the #[mimas] embedding surface, library is the standard library, and cli is the mimas binary.

License

Dual licensed under your choice of MIT or Apache 2.0.

Built on the shoulders of gc-arena, miette, and chompy; the gc-arena singleton and freeze patterns are adapted from fabricator.

About

A flexible, statically typed scripting language for Rust.

Topics

Resources

Code of conduct

Contributing

Stars

46 stars

Watchers

3 watching

Forks

Releases

Used by

Contributors

Languages