Anonymous user
MRI: Difference between revisions
Describe advantages and disadvantages.
(Describe Global VM Lock, core library, YARV and such.) |
(Describe advantages and disadvantages.) |
||
Line 1:
{{implementation|Ruby}}
{{infobox begin}}<lang ruby>
''Matz's Ruby Implementation'' or ''MRI'' refers to the original [[Ruby]] interpreter by Yukihiro Matsumoto, the inventor of Ruby. Matz and contributors wrote the interpreter in [[implemented in language::C|C language]]; MRI is also known as ''C Ruby'' or ''CRuby'', by analogy with [[CPython]].
The term "MRI" excludes other Ruby engines (such as [[JRuby]] or [[Rubinius]]). For example, one can say that Ruby has Array#sort method, and MRI uses [[Sorting algorithms/Quicksort|quicksort]]; other Ruby engines might use different sorting algorithm.
Other implementations of Ruby follow MRI. When an example on Rosetta Code works with Ruby 1.8.7, this can be MRI 1.8.7, or anything else that implements the same language.▼
▲
== Advantages ==
MRI has the ''Global VM Lock'', alias ''Giant VM Lock'' or ''GVL''. Each thread that runs Ruby code must hold this exclusive lock; therefore, multiple threads can use only CPU. (Contrast [[JRuby]], where multiple threads might use multiple CPUs.)▼
* MRI is the [[reference implementation]], and the first implementation of every new Ruby version.
* MRI can fork, though only for [[Unix]] clones (not for [[Windows]]).
* MRI can save and restore [[:Category:continuation|continuations]], though the implementation is slow because it copies the call stack.
== Disadvantages ==
▲* MRI has the ''Global VM Lock'', alias ''Giant VM Lock'' or ''GVL''.
* MRI 1.8 is slow. Programs for Ruby 1.8 often run faster in [[JRuby]] or [[Rubinius]].
== Features ==
Line 21 ⟶ 24:
# the core and standard libraries.
MRI 1.8 has a somewhat slow interpreter. MRI 1.9 has a new interpreter called Yet Another Ruby VM (YARV); it translates Ruby source code to an internal [[bytecode]], then interprets the bytecode. Ruby code can run a few times faster in MRI 1.9 than in MRI 1.8. Ruby code remains slower than C code. For example, MRI 1.9.3 changes its 'date' package from Ruby code to a C extension; this gives better performance.
|