CRuby vs MRuby FAQ

mruby, Ruby 2 Comments

At our last Ruby user group meeting it was asked, what the differences between CRuby and MRuby are. @junjis0203 wrote a MRuby FAQ. Unfortunately, it’s in Japanese. I’ve tried to translate it using http://www.excite.co.jp/world/english/ & Google translate and added my own findings.

Not all classes and method from CRuby are available in MRuby

MRuby does not guarantee to implement the features which are defined in ISO / IEC 30170

Regular Expression

Mruby allows you to switch features on or off depending on your needs and available space. These features are defined in “include/mrbconf.h”. One of the features is regular expression support, which is switched off by default.


However, undefining DISABLE_REGEXP currently results in compilation errors (tested with 6d3b35e064ce46cc97530a4fc41e64e28c555c1a).

require is not working

MRuby does not implement a “require” function, see Matz’s comment.

$! is empty

When using “rescue” to catch an exception, the variable “$!” is nil.

begin
  # ... raise_an_error ...
rescue Exception
  puts $!
end

The variable “$!” is not defined in ISO / IEC 30170. If you need to see the exception, use the “=>” syntax to assign it to a variable

begin
  # ... raise_an_error ...
rescue Exception => err
  puts err
end

Re-throwing an exception with “raise” does not work

Currently, re-throwing an exception within a “rescue” block with an “raise” without arguments is not supported.

No Big Number support

When an overflow occurs in the integer arithmetic, then MRuby will use floating point numbers instead. See Matz’s comment.

define_method and attr_reader are not implemented

These methods are now supported, see Matz’s comment.

About Frank Celler

Frank is both entrepreneur and backend developer, developing mostly memory databases for two decades. He is the lead developer of ArangoDB and co-founder of triAGENS. Try to challenge Frank asking him questions on C, C++ and MRuby. Besides Frank organizes Cologne’s nosql group & nosql conferences.
  • http://repeatedly.github.com/ Masahiro Nakagawa

    > It tries to follow ISO / IEC 30170.
    This is a mistake. I translated below.

    Even if ISO / IEC 30170 defines some classes and methods, MRuby does not guarantee to implement such features.

    • Frank Celler

       Thanks a lot. Sometimes Google translate is not that helpful to understand, what is said. Will correct.