Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PDF] Inconsistent YARV Definition #3

Open
ghost opened this issue Oct 29, 2012 · 3 comments
Open

[PDF] Inconsistent YARV Definition #3

ghost opened this issue Oct 29, 2012 · 3 comments

Comments

@ghost
Copy link

ghost commented Oct 29, 2012

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.
@Jared-Prime
Copy link

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!

@patshaughnessy
Copy link
Owner

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

@Jared-Prime
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants