From: Ken Bloom Date: 2009-03-06T04:38:31+09:00 Subject: Re: Compiling a Ruby app On Wed, 04 Mar 2009 11:52:29 -0500, Florian Gilcher wrote: > On Mar 4, 2009, at 12:47 PM, David Masover wrote: > >> Rick DeNatale wrote: >>> On Tue, Mar 3, 2009 at 5:09 AM, David Masover >>> wrote: >>> >>> >>>> Sharagoz -- wrote: >>>> >>>> >>>>> My second concern is protecting source code. I realize that >>>>> everything that can be compiled can also be decompiled, >>>>> >>>>> >>>>> >>>> That is not entirely true. Or rather, it can be "decompiled", all >>>> right, >>>> but not into anything resembling the original source code. >>>> >>>> >>> >>> Actually closer than you might think: >>> >>> require 'rubygems' >>> require 'ruby2ruby' >>> >>> >> I was speaking of compiled languages in general. As a trivial example, >> a common C optimization is to inline functions which are below a >> certain size. Now, when decompiling, how do I know what was inlined, >> and what really should be duplicate code? > > > Thats the problem of decompiling native code to a language. Usually, > Bytecodes like Java and .NET are very well decompilable, because they > retain a lot of the language instructions within the code. I suspect the > same to be true for YARV code. For example, inlined Code is possible in > Java, but there are still symbols for determining where it originates > from (for the sake of Backtraces for example). In the case of Ruby, this > also allows you to read stuff like your dynamic method example. But decompiling the Java bytecode generated by JRuby would be pretty much impossible because it has crazy things in it like call-site caches. The reason why the Java bytecode can be decompiled into the equivalent Java source code is because (a) the Java bytecode keeps a lot more information around, (b) because Java is the C of the JVM, and (c) because in Java, the JVM does the optimization, not the compiler. --Ken -- Chanoch (Ken) Bloom. PhD candidate. Linguistic Cognition Laboratory. Department of Computer Science. Illinois Institute of Technology. http://www.iit.edu/~kbloom1/