MRI and YARV Ruby implementations - what happened in Ruby 1.9?
Asked Answered
B

2

3

As I understand it, prior to Ruby 1.9, MRI and YARV were two separate implementations of the Ruby programming language.

What exactly changed in Ruby version 1.9? Was MRI abandoned in favour of YARV? Or were the two codebases merged in some way?

I have seen versions of Ruby later than 1.9 referred to as both "MRI" and "YARV" - which of these names is correct (or are they both)?

Bethezel answered 16/6, 2017 at 14:9 Comment(1)
Any reason Google can't help you? en.wikipedia.org/wiki/YARVAmbros
J
6

As I understand it, prior to Ruby 1.9, MRI and YARV were two separate implementations of the Ruby programming language.

This is only half-correct.

It is true that MRI and YARV are two separate implementations of the Ruby Programming Language.

But, it doesn't make sense to talk about YARV "prior to Ruby 1.9". YARV only ever implemented Ruby 1.9, YARV was the first implementation of Ruby 1.9. There was no YARV prior to Ruby 1.9 and there was no Ruby 1.9 prior to YARV.

What exactly changed in Ruby version 1.9? Was MRI abandoned in favour of YARV? Or were the two codebases merged in some way?

YARV only ever implemented Ruby 1.9, it didn't implement Ruby 1.8. MRI only ever implemented Ruby up to and including Ruby 1.8, it didn't implement Ruby 1.9. Thus, when Ruby 1.8 went away, also MRI went away.

YARV did re-use MRI's parser, albeit with the obvious removals, changes, and additions that make Ruby 1.9's syntax different from Ruby 1.8. (It turns out, Ruby's syntax is so insanely complex and woefully underspecified that almost all Ruby implementations re-use MRI's parser in some way. E.g. JRuby's current parser started out as a manual line-by-line port of MRI's. Rubinius went through a lot of different parsers, all of which were derived from MRI's. IronRuby uses a parser which Microsoft licensed from the Ruby.NET creators, which is in turn generated from MRI's parse.y. And so on …)

I have seen versions of Ruby later than 1.9 referred to as both "MRI" and "YARV" - which of these names is correct (or are they both)?

Neither.

Neither MRI nor YARV are versions of Ruby. They are implementations of Ruby. And MRI never implemented Ruby 1.9, only YARV, IronRuby, MacRuby, JRuby, Rubinius, Opal, Topaz, TruffleRuby, Ruby+OMR, HotRuby, unholy, and MRuby implement(ed) Ruby 1.9 or higher. (I am not sure about MagLev, I think the (abandoned) 2.0 release implemented Ruby 1.9.)

People do sometimes refer to YARV (Yet Another Ruby VM) as "MRI" (Matz's {Ruby | Reference} {Implementation | Interpreter}), but that's wrong: YARV was written by Koichi "ko1" Sasada, not Yukihiro "matz" Matsumoto, so it simply is not "Matz's Ruby Implementation". Matz's current Ruby implementation is MRuby, which is an implementation of the ISO Ruby Programming Language Specification.

Jecho answered 16/6, 2017 at 23:33 Comment(1)
So, the reference implementation of Ruby 1.8 and earlier was MRI, and the reference implementation of Ruby 1.9 and later is YARV? And the people who use the term "MRI" to refer to the reference implementation of Ruby 2.4, say, are wrong?Bethezel
E
2

YARV is not a separate implementation of Ruby. It's Ruby's virtual machine, or Yet Another Virtual Machine. When Ruby is interpreted, it is compiled into YARV instructions.

MRI is the Matz implementation of Ruby in C, which is the canonical implementation. The 2nd most used is probably JRuby, which does not use YARV because it ultimately uses the Java Virtual Machine and thus compiles to Java byte code.

Endosperm answered 16/6, 2017 at 16:17 Comment(1)
For a lot more on what's going on in MRI, I recommend: patshaughnessy.net/ruby-under-a-microscopeEndosperm

© 2022 - 2024 — McMap. All rights reserved.