Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6129965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:48:12+00:00 2026-05-23T16:48:12+00:00

I am going to learn Ruby. I know it is a interpreted language. I

  • 0

I am going to learn Ruby. I know it is a interpreted language. I know that compiled languages are translated to machine code eventually, but what does the ruby interpreter do? I read that the interpreter was written in C, but does each line of ruby convert to c, which again compiles to machine code? I also heard of JIT, but if that adds much of complexity to the answer you don’t need to answer that. What I am looking for is what happens to my Ruby code.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T16:48:13+00:00Added an answer on May 23, 2026 at 4:48 pm

    It converts the Ruby code into some form of simpler, “intermediate” representation (in recent versions, it compiles to bytecode). It also builds, in your computer’s memory, a virtual machine that simulates a physical machine executing that representation.

    This machine mirrors a physical one, at least as far as reasonable and useful. It frequently has a memory for instructions, a program counter, a stack for storing intermediate values and return adresses, etc. Some more sophisticated machines also have registers. There is a fixed and relatively primitive (compared to lanugages like Ruby, not compared to actual CPU instruction sets) instruction set. Like a CPU, the virtual machine loops endlessly:

    • Read the current instruction (identified by the program counter).
    • (Decodes it, although this is usually much simpler than in real CPUs, at least than the CISC ones.)
    • Executes it (propably manipulating stack and/or registers in the process).
    • Updates the program counter.

    With an interpreter, all of this happens through a layer of indirection. Your actual physical CPU has no idea what it’s doing. The VM is software itself, each of the steps above is delegates to the CPU in several (in cases with rather high-level bytecode instructions, possibly dozens or hundreds) physical CPU cycles. And this happens every time an instruction is read.

    Enter JIT compilation. The simplest form just replaces each bytecode instruction with a (somewhat optimized) copy of the code that would be executed when the interpreter encountered it. This already gives a speed win, e.g. the program counter manipulation can be left out. But there are even smarter variants.

    Tracing JITs, for example, start off as regular interpreter, and additionally observe the program they execute. Should they notice the program spends a lot of time in a particular section of code (almost always, a loop or a function called from loops), it starts to record what it does during this – it generates a trace. When it reaches the point where it started recording (after one iteration of the loop), it calls it a day and compiles the trace to machine code. But since it saw how the program actually behaves at runtime, it can generate code that fits this behaviour exactly. Take for example a loop adding integers. The machine code won’t contain any of the typechecks and function calls the interpreter actually perform. At least, it won’t contain most of them. It will, to ensure correctness, add checks that the conditions under which the trace was recorded (e.g. the variables involved are integers) still hold. When such s check fails, it bails out and resumes interpreting until another trace is recorded. But until that happens, it could have performed a hundred iterations at speed that rivals handwritten C code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to learn ruby on rails. I've been going through a tutorial, but
I'm going to learn Qt and I just want to know what parts of
Going back to my previous question on OCSP, does anybody know of reliable OCSP
I am going to learn Ruby on Rails (ROR) , can any one help
I'm trying to learn Ruby, and am going through some of the Project Euler
I am going through the Ruby tutorials from Learn to Program , and I
I'm going through Kent Dybvig's The Scheme Programming Language in order to learn Scheme
I'm going to learn asp.net by taking a institute coaching. I have background of
I'm trying to learn F# by going through some of the Euler problems and
Trying to learn a bit about PDO and is going through this tutorial .

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.