What are the major omissions in mruby compared to MRI?
Asked Answered
R

4

12

I'm quite interested in the mruby project, but have had no luck in finding a summarization of the major omissions in mruby compared to other, more complete Ruby implementations (most importantly, MRI).

The README in the project says that mruby implements "part of" the ISO standard for Ruby, but doesn't go into detail about which features are omitted.

Does anyone know of a list of such omissions, or is anyone familiar enough with the implementation to summarize?

Reverence answered 11/9, 2013 at 4:41 Comment(0)
R
5

So I haven't read the source closely, but after having built mruby and run the interpreter a bit, I found that the following things were missing (by no means is this a complete list, nor do I know whether these are intentional omissions or just things that haven't been written yet):

  • backticks
  • eval
  • String#scan
  • (instance|module|class)_eval with String arguments
  • Module.constants
  • Regexp
  • Process
  • Bignum
  • IO, File, and Dir
  • Encoding
  • Thread and Mutex
  • Marshal

If anyone has a more complete list, or knows the details as to whether these bits are just not yet implemented or are intentionally omitted, I'd still be curious to know.

Reverence answered 12/9, 2013 at 5:5 Comment(1)
Are these things which have been completely eliminated, or are just going to be pushed out into optional "mrbgems"?Cramped
G
4

An partial but up-to-date list of differences between Ruby MRI and MRuby can be found at https://github.com/mruby/mruby/blob/master/doc/limitations.md.

As of March 2020 these are the listed differences:

  • 1/2 gives Float(0.5) because mruby does not support Bignum.
  • Passing an Array to puts results in different output.
  • Kernel.raise without arguments does not raise the current exception within a rescue clause.
  • Fiber execution can't cross C function boundary
  • Array does not support instance variables
  • No method visibility (public/private/protected) is supported.
  • defined? is missing
  • Aliasing a global variable works in CRuby but is not part of the ISO standard.
  • An operator can't be overwritten by the user.
  • Kernel#binding is not supported.
  • Keyword arguments splats (def foo(a, b, **k)) are parsed in a different way.
  • Arguments cannot default to other destructed arguments (def foo(a, (b,c), d=b) is not valid).
  • Any redefinition of the nil? metho is ignored in conditional expressions.
Genevivegenevra answered 2/2, 2018 at 10:49 Comment(0)
W
3

Have a look at the so called mrbgems (https://github.com/mruby/mruby/tree/master/mrbgems). Some of your missing features (i.e. RegExp, eval, File) are available as an additional GEM.

Worden answered 1/10, 2013 at 18:9 Comment(0)
A
1

I just run the simple code clip with mruby and got a different result from MRI.

class Fixnum
  def +(b)
    self * b
  end
end
puts 3+4 

mruby outputs 7 while MRI outputs 12

Alfieri answered 11/9, 2013 at 4:41 Comment(2)
Are 3 and 4 a Fixnums? Are classes open? This example by itself tells us very little.Inestimable
This is the correct behaviour. See mruby limitations here: github.com/mruby/mruby/blob/master/doc/…Farmergeneral

© 2022 - 2024 — McMap. All rights reserved.