Mruby
   HOME

TheInfoList



OR:

mruby is an interpreter for the
Ruby A ruby is a pinkish red to blood-red colored gemstone, a variety of the mineral corundum ( aluminium oxide). Ruby is one of the most popular traditional jewelry gems and is very durable. Other varieties of gem-quality corundum are called ...
programming language with the intention of being lightweight and easily embeddable. The project is headed by
Yukihiro Matsumoto , also known as Matz, is a Japanese computer scientist and software programmer best known as the chief designer of the Ruby programming language and its original reference implementation, Matz's Ruby Interpreter (MRI). His demeanor has brough ...
, with over 100 contributors currently working on the project.


Features

mruby 1.0 supports the Ruby 2.1 core API, but none of the standard library. As well as being able to execute most basic Ruby code, mruby also features a
bytecode Bytecode (also called portable code or p-code) is a form of instruction set designed for efficient execution by a software interpreter. Unlike human-readable source code, bytecodes are compact numeric codes, constants, and references (norma ...
compiler and
virtual machine In computing, a virtual machine (VM) is the virtualization/emulation of a computer system. Virtual machines are based on computer architectures and provide functionality of a physical computer. Their implementations may involve specialized hardw ...
, as well as the ability to be easily embedded and integrated into C or
C++ C++ (pronounced "C plus plus") is a high-level general-purpose programming language created by Danish computer scientist Bjarne Stroustrup as an extension of the C programming language, or "C with Classes". The language has expanded significan ...
code, in a similar manner to
Lua Lua or LUA may refer to: Science and technology * Lua (programming language) * Latvia University of Agriculture * Last universal ancestor, in evolution Ethnicity and language * Lua people, of Laos * Lawa people, of Thailand sometimes referred t ...
or
Tcl TCL or Tcl or TCLs may refer to: Business * TCL Technology, a Chinese consumer electronics and appliance company **TCL Electronics, a subsidiary of TCL Technology * Texas Collegiate League, a collegiate baseball league * Trade Centre Limited ...
. mruby 2.0.0 adds support for several Ruby 2.x methods beyond Ruby 2.1. v2.0.0 also changed to variable length bytecode instructions format. mruby bytecode can be embedded in C code, and thus, can be compiled into a standalone executable. mruby also aims to be compliant with the ISO/IEC 30170:2012 standard.


Examples


Calling mruby from C

#include #include #include int main(void) Assuming that the mruby library and headers are installed, the program can be compiled and executed by running the following commands from the terminal:
$ cc example.c -lmruby -lm -o example
$ ./example


Precompiled Bytecode

mruby includes a minimalistic
virtual machine In computing, a virtual machine (VM) is the virtualization/emulation of a computer system. Virtual machines are based on computer architectures and provide functionality of a physical computer. Their implementations may involve specialized hardw ...
used to execute mruby
bytecode Bytecode (also called portable code or p-code) is a form of instruction set designed for efficient execution by a software interpreter. Unlike human-readable source code, bytecodes are compact numeric codes, constants, and references (norma ...
, nicknamed ''ritevm'':
$ mrbc test.rb
$ mruby -b test.mrb
The first command compiles Ruby code to mruby bytecode, creating a file called "test.mrb", which can then be executed by appending the "-b" flag to the normal interpreter arguments.


References

Interpreters (computing) Ruby (programming language) Software using the MIT license {{free-software-stub