WIPIVERSE All articles

mruby

mruby is a lightweight, embeddable implementation of the Ruby programming language. It is designed to be small in size, have low memory consumption, and provide a C API that enables integration of Ruby scripts into applications and devices with constrained resources.

History
mruby was initiated by Yukihiro Matsumoto, the creator of Ruby, and was first released in 2014 as part of the Ruby language ecosystem. The project was developed to address the need for a Ruby interpreter that could be embedded in environments where the full Ruby interpreter (MRI) would be too resource‑intensive.

Design goals

  • Small footprint: The core interpreter, when built with default options, occupies only a few hundred kilobytes.
  • Embeddability: Provides a well‑defined C API that allows host programs to evaluate Ruby code, expose native functions to Ruby, and manage the interpreter lifecycle.
  • Portability: Designed to compile on a wide range of platforms, including microcontrollers, mobile devices, and standard desktop operating systems.
  • Compatibility: Supports a substantial subset of the Ruby 2.x language features, though not the entire standard library of MRI Ruby.

Key components

  • mruby interpreter: The core bytecode interpreter written in C.
  • mrbgems: A package system analogous to RubyGems, allowing distribution of libraries written for mruby.
  • mruby‑c: A command‑line tool for compiling Ruby source files into bytecode (.mrb files) and executing them.
  • mruby‑test: A lightweight testing framework for mruby code.

Typical usage patterns

  1. Embedding: Applications embed mruby to provide user‑extendable scripting capabilities, for example in game engines, GUI tools, or IoT firmware.
  2. Standalone scripts: Developers can write scripts that run directly with the mruby interpreter, useful for rapid prototyping on constrained systems.
  3. Extension development: Native extensions can be written in C and exposed to Ruby code through the mruby C API, enabling performance‑critical operations.

License
mruby is distributed under the 2‑clause BSD license, allowing commercial and open‑source use with minimal restrictions.

Relevant projects and derivatives

  • mruby‑on‑WebAssembly: Projects that compile mruby to WebAssembly for execution in web browsers.
  • mruby‑bindings: Various language bindings (e.g., for Java, Python) that allow other languages to interoperate with mruby code.

See also

  • Ruby (programming language)
  • MRI (Matz's Ruby Interpreter)
  • Lua (another lightweight embeddable scripting language)

References

  • mruby official website and documentation (https://mruby.org)
  • "mruby: Lightweight Ruby Implementation" – presentation by Yukihiro Matsumoto at RubyConf 2014.

This entry reflects information available from publicly documented sources as of the knowledge cutoff date.

Browse

More topics to explore

    Browse all articles