# Compile/Close Ruby Code

**URL:** <https://www.ruby-forum.com/t/compile-close-ruby-code/184878>\
**Category:** Ruby\
**Created:** [March 9, 2010, 8:20pm UTC](https://www.ruby-forum.com/t/compile-close-ruby-code/184878 "2010-03-09T20:20:51Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![gurbux](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/94ad74/32.png) [@gurbux](https://www.ruby-forum.com/u/gurbux)\
**Post date:** [March 9, 2010, 8:20pm UTC](https://www.ruby-forum.com/t/compile-close-ruby-code/184878/1 "2010-03-09T20:20:51Z")

</div>

I write scripts under Linux using Ruby.

It wouldn’t matter releasing the code as long as the code is MINE.  
However, if I develop software for a company, and if a rival gets a hold  
of the code; you can consider me fired.

So what are the options?

I believe JRuby or IronRuby hide the code right? I haven’t used these,  
so please inform me.

What about Ruby2Exe? Is it any good? Would it please Windows users?

What about closing the code in UNIX or Linux?

Thanks!

---

<div class="post-metadata">

**Author:** ![gurbux](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/94ad74/32.png) [@gurbux](https://www.ruby-forum.com/u/gurbux)\
**Post date:** [March 9, 2010, 11:11pm UTC](https://www.ruby-forum.com/t/compile-close-ruby-code/184878/2 "2010-03-09T23:11:24Z")

</div>

On 3/9/2010 12:20 PM, Aytug G. wrote:

> What about Ruby2Exe? Is it any good? Would it please Windows users?
> 
> What about closing the code in UNIX or Linux?
> 
> Thanks!

I don’t about Ruby2Exe, as I understand it, it’s been replaced by OCRA,  
which I’ve had good luck with. Of course, with both of them, it’s not  
going to be very difficult for someone with a little bit of knowledge to  
extract the code. Of course even technologies built on Java or .NET are  
fairly easy to reverse with a little knowledge (Or written in C for that  
matter). I guess the real question is why in the world would you  
release your code to a rival? Suffice it to say, if you have someone  
actively trying to steal your code, there is no programming language  
that will stop them. There are tools that can help make it more  
difficult, but it’s always possible by someone sufficiently  
knowledgeable.

---

<div class="post-metadata">

**Author:** ![gurbux](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/94ad74/32.png) [@gurbux](https://www.ruby-forum.com/u/gurbux)\
**Post date:** [March 9, 2010, 11:40pm UTC](https://www.ruby-forum.com/t/compile-close-ruby-code/184878/3 "2010-03-09T23:40:05Z")

</div>

On Mar 9, 2010, at 11:20, Aytug G. wrote:

> I write scripts under Linux using Ruby.
> 
> It wouldn’t matter releasing the code as long as the code is MINE.  
> However, if I develop software for a company, and if a rival gets a hold  
> of the code; you can consider me fired.
> 
> So what are the options?

License your software and hire a lawyer for people who violate your  
license and/or copyrights.

Even if you were to obscure the source somehow there’s no way to prevent  
people from reversing the process.

---

<div class="post-metadata">

**Author:** ![gurbux](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/94ad74/32.png) [@gurbux](https://www.ruby-forum.com/u/gurbux)\
**Post date:** [March 10, 2010, 12:35am UTC](https://www.ruby-forum.com/t/compile-close-ruby-code/184878/4 "2010-03-10T00:35:41Z")

</div>

On 2010-03-09, Aytug G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> It wouldn’t matter releasing the code as long as the code is MINE.  
> However, if I develop software for a company, and if a rival gets a hold  
> of the code; you can consider me fired.

Why?

I work for a company. They pay me to write code, all of which is at the  
very least shown to other people, and much of which we release under  
GPL.

> What about closing the code in UNIX or Linux?

In general:

1. You can’t.
2. You shouldn’t try.

It’s not worth it. There’s no way to make something other people can  
run  
but can’t figure out how it runs.

-s

---

<div class="post-metadata">

**Author:** ![gurbux](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/94ad74/32.png) [@gurbux](https://www.ruby-forum.com/u/gurbux)\
**Post date:** [March 9, 2010, 11:54pm UTC](https://www.ruby-forum.com/t/compile-close-ruby-code/184878/5 "2010-03-09T23:54:08Z")

</div>

On Tue, Mar 9, 2010 at 10:09 PM, Walton H.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)wrote:

> > so please inform me.  
> > extract the code. Of course even technologies built on Java or .NET are  
> > fairly easy to reverse with a little knowledge (Or written in C for that  
> > matter). I guess the real question is why in the world would you  
> > release your code to a rival? Suffice it to say, if you have someone  
> > actively trying to steal your code, there is no programming language  
> > that will stop them. There are tools that can help make it more  
> > difficult, but it’s always possible by someone sufficiently knowledgeable.

The question of obfuscating code comes up a lot here. One of the more  
reasonable desires for it is to stop a client tinkering with it, or  
otherwise  
control how it is updated with respect to support etc. I am sure python,  
perl,Tcl mailing lists are full of this too.

Generally people are happy with packaging solutions, where the source is  
not sitting on the file system and so cannot be tinkered with and  
repackaged  
easily. JRuby offers a few options here with Rawr possibly, and Warbler  
allows  
you to create self contained Rails apps that are indistinguishable from  
regular  
java WAR files. Crate is another packaging solution that I have heard of  
that  
may be useful.

Once you are distributing your code, these options will only hide your  
code  
from casual snooping. A determined individual will be able to unpackage  
the  
application, inspect the code and repackage it. Signing the package may  
provide some options to help you control this problem, but it wont hide  
your source.

As to why Ruby source is being singled out in this case I don’t know.  
Aytug,  
if your employer takes a hard line on this, my sympathies. My experience  
on  
this  
is that naive false assumptions on how ‘protected’ the source is by  
language  
can only rarely be undone. Its usually an emotive problem.

regards,  
Richard

---

<div class="post-metadata">

**Author:** ![gurbux](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/94ad74/32.png) [@gurbux](https://www.ruby-forum.com/u/gurbux)\
**Post date:** [March 10, 2010, 3:57pm UTC](https://www.ruby-forum.com/t/compile-close-ruby-code/184878/6 "2010-03-10T15:57:30Z")

</div>

On Tue, Mar 9, 2010 at 1:20 PM, Aytug G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> I write scripts under Linux using Ruby.
> 
> It wouldn’t matter releasing the code as long as the code is MINE.  
> However, if I develop software for a company, and if a rival gets a hold  
> of the code; you can consider me fired.
> 
> So what are the options?
> 
> I believe JRuby or IronRuby hide the code right? I haven’t used these,  
> so please inform me.

There are several vendors who use JRuby to pre-compile code for  
release as packaged software. The pre-compiled code is just JVM  
bytecode, so it’s possible to decompile it to something…but it would  
be hard to duplicate it without a lot of effort. Since you can also  
bundle it up inside a .jar file and provide a simple executable, most  
users would never bother cracking it open. Using JRuby has the added  
benefit that your bundle doesn’t need to be rebuilt for any platform;  
if there’s a JVM installed (and there probably is), it will just work.

My opinion: despite what others on this thread have said, sometimes  
there’s a real need to at least make it difficult to reverse-engineer  
code when you ship a packaged application. Using JRuby is probably the  
easiest way right now.

- Charlie

---

<div class="post-metadata">

**Author:** ![gurbux](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/94ad74/32.png) [@gurbux](https://www.ruby-forum.com/u/gurbux)\
**Post date:** [March 10, 2010, 8:47am UTC](https://www.ruby-forum.com/t/compile-close-ruby-code/184878/7 "2010-03-10T08:47:47Z")

</div>

OK, I see. I shouldn’t bother too much about hiding the code then.

Thanks for the explanation guys!
