# mruby/mruby

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/mruby-mruby).**

5,584 stars · 838 forks · C · MIT

## Links

- GitHub: https://github.com/mruby/mruby
- awesome-repositories: https://awesome-repositories.com/repository/mruby-mruby.md

## Description

mruby is a lightweight Ruby interpreter designed to be embedded into C applications. It compiles Ruby source code into a compact, platform-independent bytecode that executes on a register-based virtual machine, and exposes a stable C API for host programs to initialize the interpreter, load bytecode, and invoke Ruby methods at runtime.

The interpreter distinguishes itself through a tightly coupled parser and compiler that performs lexical analysis, syntax parsing, and bytecode generation in a single pass without constructing an intermediate AST, minimizing memory overhead. It also includes a gems packaging system that organizes C extensions and Ruby libraries into versioned packages with metadata files for runtime loading and resolution, and a single-file build system that assembles all interpreter source and headers into one C file and one header for trivial integration into other projects.

The project covers the full pipeline of translating Ruby source into portable bytecode, packaging extensions as gems, and distributing a minimal runtime for resource-constrained environments. Its documentation and build surface are centered around the single-file library distribution, which simplifies inclusion in host projects without complex build steps.

## Tags

### Programming Languages & Runtimes

- [Bytecode Interpreters](https://awesome-repositories.com/f/programming-languages-runtimes/bytecode-interpreters.md) — An embeddable interpreter that compiles Ruby source code into portable bytecode for execution in C applications.
- [Source-to-Bytecode Compilers](https://awesome-repositories.com/f/programming-languages-runtimes/bytecode-compiled-languages/source-to-bytecode-compilers.md) — Compiles Ruby source files into portable bytecode that any compatible interpreter can load and run. ([source](https://cdn.jsdelivr.net/gh/mruby/mruby@main/README.md))
- [C-Based Embedding APIs](https://awesome-repositories.com/f/programming-languages-runtimes/c-based-embedding-apis.md) — Exposes a stable C interface for host applications to initialize the interpreter, load bytecode, and invoke Ruby methods.
- [Embedded Script Execution](https://awesome-repositories.com/f/programming-languages-runtimes/embedded-script-execution.md) — Links the library into a C application so it can execute Ruby scripts at runtime. ([source](https://cdn.jsdelivr.net/gh/mruby/mruby@main/README.md))
- [Embedded Scripting Engines](https://awesome-repositories.com/f/programming-languages-runtimes/embedded-scripting-engines.md) — A C library that links into host programs to run Ruby scripts at runtime without a separate runtime environment.
- [Register-Based Bytecode](https://awesome-repositories.com/f/programming-languages-runtimes/register-based-bytecode.md) — Uses a fixed set of virtual registers instead of a stack to execute bytecode, reducing instruction count and improving speed.
- [Scripting Runtimes](https://awesome-repositories.com/f/programming-languages-runtimes/scripting-runtimes.md) — Adds a lightweight Ruby interpreter to a C application so it can run user-defined scripts at runtime.
- [Single-Pass Compilation](https://awesome-repositories.com/f/programming-languages-runtimes/bytecode-compilation/single-pass-compilation.md) — Combines lexical analysis, syntax parsing, and bytecode generation into a single pass without intermediate AST construction.
- [Cross-Platform Compilers](https://awesome-repositories.com/f/programming-languages-runtimes/cross-platform-compilers.md) — Compiles Ruby source code into portable bytecode that runs on any platform with a compatible interpreter.
- [Minimal Ruby Distributions](https://awesome-repositories.com/f/programming-languages-runtimes/runtime-execution-environments/runtime-environments/language-runtimes/ruby-environments/minimal-ruby-distributions.md) — Packages a stripped-down Ruby runtime for resource-constrained environments like embedded systems or IoT devices.

### Software Engineering & Architecture

- [Single-File Libraries](https://awesome-repositories.com/f/software-engineering-architecture/single-file-libraries.md) — Ships a single-file C library distribution for trivial integration into host projects.
- [Compile-Time Code Generation](https://awesome-repositories.com/f/software-engineering-architecture/compile-time-code-generation.md) — Translates Ruby source into bytecode ahead of execution using a recursive-descent parser and code generator.

### Part of an Awesome List

- [Single-File C Library Builds](https://awesome-repositories.com/f/awesome-lists/devtools/build-and-compilation/single-file-compilations-and-runs/single-file-c-library-builds.md) — Assembles all interpreter source and headers into one C file and one header for trivial integration into other projects.
- [Language Implementations](https://awesome-repositories.com/f/awesome-lists/devtools/language-implementations.md) — Lightweight, embeddable Ruby implementation.
- [Ruby Frameworks and Tools](https://awesome-repositories.com/f/awesome-lists/devtools/ruby-frameworks-and-tools.md) — Lightweight Ruby implementation.

### DevOps & Infrastructure

- [Ruby Gem Packaging](https://awesome-repositories.com/f/devops-infrastructure/ruby-gem-packaging.md) — Organises C extensions and Ruby libraries into versioned packages with metadata files for runtime loading and resolution.
