# Compiling ruby code

**URL:** <https://www.ruby-forum.com/t/compiling-ruby-code/89952>\
**Category:** Ruby\
**Created:** [March 29, 2006, 2:37pm UTC](https://www.ruby-forum.com/t/compiling-ruby-code/89952 "2006-03-29T14:37:30Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![z1n](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e8c25b/32.png) [@z1n](https://www.ruby-forum.com/u/z1n)\
**Post date:** [March 29, 2006, 2:37pm UTC](https://www.ruby-forum.com/t/compiling-ruby-code/89952/1 "2006-03-29T14:37:30Z")

</div>

i know very little about ruby, have only looked shortly at rails

Is it possible to compile my own code so that it cannot be viewed by  
others ?

much like the zend compiler does for php

---

<div class="post-metadata">

**Author:** ![z1n](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e8c25b/32.png) [@z1n](https://www.ruby-forum.com/u/z1n)\
**Post date:** [March 29, 2006, 2:58pm UTC](https://www.ruby-forum.com/t/compiling-ruby-code/89952/2 "2006-03-29T14:58:18Z")

</div>

Yes and no.

There is Rubyscript2exe:  
[http://www.erikveen.dds.nl/rubyscript2exe/index.html](http://www.erikveen.dds.nl/rubyscript2exe/index.html)

That said suspect it would not be too hard to hack into the exe and  
retrieve  
the script, as I believe it stores the script text and then interprets  
it  
using an embedded interpreter. I think any language that’s interpreted  
will  
be hackable, question is how hard you can make it for them. I also  
suspect  
we can make it a lot harder in Ruby 2.0, with a Ruby VM.

You might also want to check out:  
All In One Ruby - [AllInOneRuby - A "Just-in-Time and Temporary Installation of Ruby"](http://www.erikveen.dds.nl/allinoneruby/index.html)

=Bill.Barnhill

---

<div class="post-metadata">

**Author:** ![z1n](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e8c25b/32.png) [@z1n](https://www.ruby-forum.com/u/z1n)\
**Post date:** [March 29, 2006, 2:58pm UTC](https://www.ruby-forum.com/t/compiling-ruby-code/89952/3 "2006-03-29T14:58:53Z")

</div>

Simon Nielsen wrote:

> i know very little about ruby, have only looked shortly at rails
> 
> Is it possible to compile my own code so that it cannot be viewed by  
> others ?
> 
> much like the zend compiler does for php

There’s currently no ruby compiler.

If you want better performance take look at YARV project (  
[YARV: Yet Another Ruby VM](http://www.atdot.net/yarv/) )

If you want to protect your code from reuse, here are some well-known  
rules ( [http://www.faqs.org/docs/artu/ch01s06.html](http://www.faqs.org/docs/artu/ch01s06.html) )

Just INVERT them all and apply INVERTED rules to your code and mind -  
and there will be no need to compile or obfuscate your code ever :)))

---

<div class="post-metadata">

**Author:** ![z1n](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e8c25b/32.png) [@z1n](https://www.ruby-forum.com/u/z1n)\
**Post date:** [March 29, 2006, 3:50pm UTC](https://www.ruby-forum.com/t/compiling-ruby-code/89952/4 "2006-03-29T15:50:21Z")

</div>

Le 29 mars 06, à 07:59, Damphyr a écrit :

> Well, in this case it’s not exactly hard, it’s more like childlike  
> easy:  
> rubyscript2exe untars the whole ruby environment, together with your  
> script, in the temp directory. Getting the source means browsing the  
> temp folder 🙂

It’s even easier than that. The executable created has an option  
–eee-justextract, which will extract the whole thing in the current  
directory…

Guillaume.

---

<div class="post-metadata">

**Author:** ![z1n](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e8c25b/32.png) [@z1n](https://www.ruby-forum.com/u/z1n)\
**Post date:** [March 29, 2006, 3:59pm UTC](https://www.ruby-forum.com/t/compiling-ruby-code/89952/5 "2006-03-29T15:59:26Z")

</div>

Thanks for the link dseverin! Definitely add to my to-do list.

James H.

---

<div class="post-metadata">

**Author:** ![z1n](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e8c25b/32.png) [@z1n](https://www.ruby-forum.com/u/z1n)\
**Post date:** [March 29, 2006, 3:01pm UTC](https://www.ruby-forum.com/t/compiling-ruby-code/89952/6 "2006-03-29T15:01:29Z")

</div>

Bill B. wrote:

> Yes and no.
> 
> There is Rubyscript2exe:  
> [http://www.erikveen.dds.nl/rubyscript2exe/index.html](http://www.erikveen.dds.nl/rubyscript2exe/index.html)
> 
> That said suspect it would not be too hard to hack into the exe and retrieve  
> the script, as I believe it stores the script text and then interprets it  
> using an embedded interpreter. I think any language that’s interpreted will  
> Well, in this case it’s not exactly hard, it’s more like childlike easy:  
> rubyscript2exe untars the whole ruby environment, together with your  
> script, in the temp directory. Getting the source means browsing the  
> temp folder 🙂  
> Cheers,  
> V.-  
> –  
> [http://www.braveworld.net/riva](http://www.braveworld.net/riva)
