ruby-under-a-microscope icon indicating copy to clipboard operation
ruby-under-a-microscope copied to clipboard

[PDF] Inconsistent YARV Definition

Open ghost opened this issue 13 years ago • 3 comments

page 10

  • Next in Chapter 2, How Ruby Executes Your Code, I pick up the story from where Chapter 1 left off and describe how Ruby’s virtual machine, called “Yet Another Virtual Machine” (YARV) executes your program.

page 44

  • With Ruby 1.9, the Ruby core team introduced something called “Yet Another Ruby Virtual Machine” (or YARV), which actually executes your Ruby code.

ghost avatar Oct 29 '12 23:10 ghost

I agree, the definitions seem inconsistent. I was also confused by the comparison to the JVM.

There’s one final step on your code’s journey through Ruby: compilation. With Ruby 1.9, the Ruby core team introduced something called “Yet Another Ruby Virtual Machine” (or YARV), which actually executes your Ruby code. (Kindle Locations 617-619).

It was not immediately clear to me that YARV does not actually compile bytecode (or does it)? Being unknowledgeable about such things, a more precise definition would help greatly.

PS. Overall, I'm enjoying the book and learning a ton!

Jared-Prime avatar Nov 02 '12 14:11 Jared-Prime

Hi - glad you're enjoying the book!

I'm going through the text this weekend fixing all the typos and issues, and will update the download kit tomorrow.

So I rewrote this paragraph to be a bit more clear about this - does this sound better?

However if you have upgraded to Ruby 1.9 or Ruby 2.0, then Ruby is still not quite ready to run your code. There’s one final step on your code’s journey through Ruby: compilation. With Ruby 1.9, the Ruby core team introduced something called “Yet Another Ruby Virtual Machine” (or YARV), which actually executes your Ruby code. At a high level, this is the same idea behind the much more famous Java Virtual Machine (or JVM) used by Java and many other languages. To use the JVM, you first compile your Java code into “byte code,” a series of low level instructions that the JVM understands. Starting with version 1.9, Ruby works the same way! The only differences are that:

• Ruby doesn’t expose the compiler to you as a separate tool; instead it automatically compiles your Ruby code into byte code instructions internally without you ever realizing it.

• MRI Ruby also never compiles your Ruby code all the way to machine language. As you can see in the next diagram, Ruby interprets the byte code instructions. The JVM, however, can compile some of the byte code instructions all the way into machine language using its “hotspot” or JIT compiler.

cheers - pat

patshaughnessy avatar Nov 10 '12 14:11 patshaughnessy

that's a bit clearer now that I've been able to process YARV (no pun intended)

Jared-Prime avatar Nov 12 '12 02:11 Jared-Prime