# Ruby language: compiled or jited?

**URL:** <https://rubytalk.org/t/ruby-language-compiled-or-jited/51745>\
**Category:** ruby-talk\
**Created:** [15 February 2009 01:41 UTC](https://rubytalk.org/t/ruby-language-compiled-or-jited/51745 "2009-02-15T01:41:52Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Soh\_Dubom](https://avatars.discourse-cdn.com/v4/letter/s/278dde/32.png) [@Soh\_Dubom](https://rubytalk.org/u/Soh_Dubom)\
**Post date:** [15 February 2009 01:41 UTC](https://rubytalk.org/t/ruby-language-compiled-or-jited/51745/1 "2009-02-15T01:41:52Z")

</div>

Is it true that ruby language will change to a compiled or jited  
language, like .net or java?

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![Ken\_Bloom](https://avatars.discourse-cdn.com/v4/letter/k/f08c70/32.png) [@Ken\_Bloom](https://rubytalk.org/u/Ken_Bloom)\
**Post date:** [15 February 2009 04:08 UTC](https://rubytalk.org/t/ruby-language-compiled-or-jited/51745/2 "2009-02-15T04:08:28Z")

</div>

Ruby 1.9 introduced a bytecode-based interpreter (which converts your  
program to its own bytecodes and then interprets those bytecodes a la  
very old Java VMs). JRuby already has an interpreter which compiles to  
the Java VM, and these days that is JITted, so I guess it's already  
changed.

--Ken

> **···**
>
> On Sat, 14 Feb 2009 20:41:52 -0500, Soh Dubom wrote:
> 
> > Is it true that ruby language will change to a compiled or jited  
> > language, like .net or java?
> 
> --  
> Chanoch (Ken) Bloom. PhD candidate. Linguistic Cognition Laboratory.  
> Department of Computer Science. Illinois Institute of Technology.  
> [http://www.iit.edu/~kbloom1/](http://www.iit.edu/~kbloom1/)

---

<div class="post-metadata">

**Author:** ![Soh\_Dubom](https://avatars.discourse-cdn.com/v4/letter/s/278dde/32.png) [@Soh\_Dubom](https://rubytalk.org/u/Soh_Dubom)\
**Post date:** [15 February 2009 12:04 UTC](https://rubytalk.org/t/ruby-language-compiled-or-jited/51745/3 "2009-02-15T12:04:16Z")

</div>

Ken Bloom wrote:

> **···**
>
> > On Sat, 14 Feb 2009 20:41:52 -0500, Soh Dubom wrote:
> > 
> > > Is it true that ruby language will change to a compiled or jited  
> > > language, like .net or java?
> > 
> > Ruby 1.9 introduced a bytecode-based interpreter (which converts your  
> > program to its own bytecodes and then interprets those bytecodes a la  
> > very old Java VMs). JRuby already has an interpreter which compiles to  
> > the Java VM, and these days that is JITted, so I guess it's already  
> > changed.
> > 
> > --Ken
> 
> Hum, does it make Ruby 1.9 a compiled language as, let's say C#? The  
> reason I got interested in Ruby is because it's an interpreted language  
> and I don't have to, for every change, re-compiled it  
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![Zac\_Brown](https://avatars.discourse-cdn.com/v4/letter/z/7c8e57/32.png) [@Zac\_Brown](https://rubytalk.org/u/Zac_Brown)\
**Post date:** [15 February 2009 13:26 UTC](https://rubytalk.org/t/ruby-language-compiled-or-jited/51745/4 "2009-02-15T13:26:22Z")

</div>

Ruby 1.9 would be considered a compiled language since there is a process of converting Ruby code into bytecode (analogous to a C compiler converting C code into Assembly). However as far as I know, the 1.9 VM isn't a JIT. It merely "compiles" that code each time and runs. Like Ken said though, since JRuby runs on the JVM, it technically JIT'd.

Every language has to be interpreted or parsed in some fashion so its always going to take at least some time (even if miniscule) to parse the program. If its a VM based language it'll then either generate bytecode and run that on the VM, otherwise it will just begin executing code based on what the parse tree looks like (a la Ruby 1.8.x).

So in short the process between compiling and interpreting isn't hugely different from your point of view as far as time goes and you'll still have to wait, but its not going to be any great length of time (unless its a huge script).

Hope that helps.

-Zac

Note: If I'm wrong about any of these details regarding Ruby, someone please correct me :).

> **···**
>
> On Feb 15, 2009, at 7:04 AM, Soh Dubom wrote:
> 
> > Ken Bloom wrote:
> > 
> > > On Sat, 14 Feb 2009 20:41:52 -0500, Soh Dubom wrote:
> > > 
> > > > Is it true that ruby language will change to a compiled or jited  
> > > > language, like .net or java?
> > > 
> > > Ruby 1.9 introduced a bytecode-based interpreter (which converts your  
> > > program to its own bytecodes and then interprets those bytecodes a la  
> > > very old Java VMs). JRuby already has an interpreter which compiles to  
> > > the Java VM, and these days that is JITted, so I guess it's already  
> > > changed.
> > > 
> > > --Ken
> > 
> > Hum, does it make Ruby 1.9 a compiled language as, let's say C#? The  
> > reason I got interested in Ruby is because it's an interpreted language  
> > and I don't have to, for every change, re-compiled it

---

<div class="post-metadata">

**Author:** ![Ken\_Bloom](https://avatars.discourse-cdn.com/v4/letter/k/f08c70/32.png) [@Ken\_Bloom](https://rubytalk.org/u/Ken_Bloom)\
**Post date:** [15 February 2009 17:13 UTC](https://rubytalk.org/t/ruby-language-compiled-or-jited/51745/5 "2009-02-15T17:13:22Z")

</div>

Ruby 1.9 doesn't have an ahead-of-time byte compilation mode as far as I  
know. That means you only have to run one command to run your modified  
code. Every time you run your script, the interpreter parses it and byte  
compiles it, which then results in a speed increase when the interpreter  
runs the script. JRuby has a mode where it parses and compiles the script  
every time (the jruby command) and an ahead-of-time compilation mode (the  
jrubyc command).

So Ruby 1.9 can run like perl/python. JRuby can run like perl/python or  
like C#.

--Ken

> **···**
>
> On Sun, 15 Feb 2009 07:04:16 -0500, Soh Dubom wrote:
> 
> > Ken Bloom wrote:
> > 
> > > On Sat, 14 Feb 2009 20:41:52 -0500, Soh Dubom wrote:
> > > 
> > > > Is it true that ruby language will change to a compiled or jited  
> > > > language, like .net or java?
> > > 
> > > Ruby 1.9 introduced a bytecode-based interpreter (which converts your  
> > > program to its own bytecodes and then interprets those bytecodes a la  
> > > very old Java VMs). JRuby already has an interpreter which compiles to  
> > > the Java VM, and these days that is JITted, so I guess it's already  
> > > changed.
> > > 
> > > --Ken
> > 
> > Hum, does it make Ruby 1.9 a compiled language as, let's say C#? The  
> > reason I got interested in Ruby is because it's an interpreted language  
> > and I don't have to, for every change, re-compiled it
> 
> --  
> Chanoch (Ken) Bloom. PhD candidate. Linguistic Cognition Laboratory.  
> Department of Computer Science. Illinois Institute of Technology.  
> [http://www.iit.edu/~kbloom1/](http://www.iit.edu/~kbloom1/)

---

<div class="post-metadata">

**Author:** ![David\_Masover](https://avatars.discourse-cdn.com/v4/letter/d/50afbb/32.png) [@David\_Masover](https://rubytalk.org/u/David_Masover)\
**Post date:** [16 February 2009 07:49 UTC](https://rubytalk.org/t/ruby-language-compiled-or-jited/51745/6 "2009-02-16T07:49:10Z")

</div>

Soh Dubom wrote:

> Ken Bloom wrote:  
> &nbsp;&nbsp;
> 
> > > Is it true that ruby language will change to a compiled or jited  
> > > language, like .net or java?  
> > > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
> > 
> > [snip]  
> > &nbsp;&nbsp;&nbsp;&nbsp;  
> > Hum, does it make Ruby 1.9 a compiled language as, let's say C#? The reason I got interested in Ruby is because it's an interpreted language and I don't have to, for every change, re-compiled it  
> > &nbsp;&nbsp;  
> > The short answer is: Yes, it's interpreted, in roughly the same way that Perl, Python, PHP, and JavaScript are interpreted. No, you don't have to recompile anything after every change -- in fact, many frameworks (Rails included) have a "development mode" which lets most changes be incorporated immediately into your app while it's running. And yes, it does mean you probably have to give your source code to anyone who needs to run your program on their local machine.

The longer answers you are getting are about the technical details, probably pre-emptively heading off questions like "If it's interpreted, isn't it slower?" And it turns out, what you're talking about is completely different than the question of whether a language is actually compiled to native code.

For example, there's no reason you couldn't write a shell script which, when it's run, immediately compiles a large string (as C) into a binary and runs that. Similarly, it's probably possible to bundle up a JAR containing both JRuby and your app, and whether or not any of it was actually compiled ahead of time, such that it can simply be run as a Java program. There are even projects which embed Ruby source code and the Ruby interpreter to produce a single EXE (on Windows). Similarly, gcj can compile Java bytecode down to actual binary, and LLVM takes languages like C and makes them JIT.

So the longer answer is, unless your concern is performance, you should only care about the shorter answer.

> **···**
>
> > > On Sat, 14 Feb 2009 20:41:52 -0500, Soh Dubom wrote:

---

<div class="post-metadata">

**Author:** ![Soh\_Dubom](https://avatars.discourse-cdn.com/v4/letter/s/278dde/32.png) [@Soh\_Dubom](https://rubytalk.org/u/Soh_Dubom)\
**Post date:** [16 February 2009 11:49 UTC](https://rubytalk.org/t/ruby-language-compiled-or-jited/51745/7 "2009-02-16T11:49:08Z")

</div>

thanks David ... the short answer is my case scenario ... i'm not really  
concerned with exceptional performance since my projects are relatively  
small ones...

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
