home shape

CRuby vs. MRuby: Understanding the Differences | ArangoDB 2012

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.

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

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

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

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.

Frank Celler

Frank Celler

Frank is both entrepreneur and backend developer, developing mostly memory databases for two decades. He is the CTO and co-founder of ArangoDB. Try to challenge Frank asking him questions on C, C++ and MRuby. Besides Frank organizes Cologne’s NoSQL group & is an active member of NoSQL community.


  1. Masahiro Nakagawa on June 24, 2012 at 5:29 pm

    > 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 on June 24, 2012 at 7:36 pm

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

Leave a Comment

Get the latest tutorials, blog posts and news: