logo       

Re: Compile Ruby Code?: msg#00064

lang.jruby.user

Subject: Re: Compile Ruby Code?

Being able to turn ruby as native java classes sounds great, I have to confess though that im not up on the java language. Recently we have evaluated the various languages suitable for web programming for commercial purposes. Prior to recently we have programmed for the Windows desktop using Pascal (Delphi).
And while Ruby is our choice of language on technical and productivity grounds
is is quite new and not standard/mainstream. Hence the look at java and how we
can use that to enable ruby to be deployed to existing mainstream servers.

I think ultimately it would be great to be able to distribute java bytecode
(the ruby embedded within). Being able to run ruby on java is great, really
great, but being able to say this runs on ruby or java!

"What this gets you is a way to make Ruby feel a bit more like Java
code, and a minimal obfuscation of Ruby script code within a class
file. Would something like this provide any value?"

Yes! But like I say I am not a java programmer so am not sure what the java feel is. Do you think doing ruby in this way would put constraints on the way you use ruby? For example things you can and cant do?




Charles O Nutter wrote:

I certainly agree with the "easier to sell Java". That's one of the
founding principals of my work personally on JRuby...trying to subvert
the system and make Ruby possible within the Java world.

There is a short-term "compilation" option I have been considering
that perhaps you might have an opinion on. In the absence of a real
compiler, there is some value in being able to turn Ruby scripts into
Java class files, even if there's little actual compilation being
done. What we could do is simply serialize or embed the Ruby script
into a class file along with wrapper code to handle JRuby specifics.
What you would essentially have is a class that could be classloaded
as normal, and that loading process would prime JRuby with appropriate
Ruby definitions. Ultimately what happens behind the scenes is just
that the class itself calls out to JRuby or JRuby is made aware of the
class, and from there the normal Ruby script parsing happens.

Ultimately, since Ruby is far more dynamic a language (not just
dynamically typed, but really "dynamic"), we'll have to do something
like this anyway...there's just no way on current JVMs that Ruby code
can be run directly.

What this gets you is a way to make Ruby feel a bit more like Java
code, and a minimal obfuscation of Ruby script code within a class
file. Would something like this provide any value?

On 2/22/06, Kris Leech <krisleech@xxxxxxxxxxxxxxx> wrote:

Thanks for your comments Charles. I interested in JRuby for two reasons,
both of almost equal weight, firstly to allow ruby code to be deployed
to servers without ruby installed. This is often the case in the public
sector and secondly as a layer of protection for Intellectual Property.
I think the combination of bytecode and obfuscation would be enough to
make reverse engineering the code more costly than writing it from
scratch :)

I am aware of one company writing an obfuscator, but they only answered
one email I sent so I dont know if it is due any time soon. However I
guess it would not be very difficult to write one. It would just be a
fancy find and replace on the source code.

Am I right in thinking JRuby can be used in two ways, firstly it can be
used to run ruby code using java (java interpreter) and secondly it
allows ruby code to be embedded in Java applications?

If ruby code can be put inside a Java applications not only can we run
our code on Java but we can actually distribute a java application (with
the ruby hidden inside). At the moment in certain sectors its easier to
sell java.

Many Thanks, K.



Charles O Nutter wrote:


Unless (or until) a reverse-compiler were created (which probably
would not be a high priority at first) there wouldn't be an easy way
to reverse it. However, Java bytecode isn't terribly complicated, and
the source for the compiler would be open, so eventually someone would
be able to reverse the process.

If you are looking to protect Ruby code this way, an additional
obfuscation step might be your best bet, so that even if the code were
decompiled it would be unreadable. An obfuscator that takes existing
Java classes and mutilates them might also be an option. This would
obviously make debugging more difficult, and we do not have plans to
write an obfuscator at this time.

- Charlie

On 2/20/06, Kris Leech <krisleech@xxxxxxxxxxxxxxx> wrote:



Thanks Tom for the swift reply, can ByteCode be easily transformed back
in to ruby code?


Thomas E Enebo wrote:




On Mon, 20 Feb 2006, Kris Leech defenestrated me:






Great work with JRuby and the opening up of platform coverage. I was
looking at JRuby as a means of protecting Intellectual Property ie.
distributing compiled or byte code instead of source code. But it
appears that JRuby is an interpretor only, at the moment anyway.

Are there any plans to create a ruby bytecode pre-compiler?





Yes, but not in the immediate future. Charles Nutter has been in
the progress of converting the evaluation part of JRuby to be iterative
instead of recursive. An iterative evaluation model should be fairly
straight-forward to translate into instructions. So once that is done
we will look at compilation.

-Tom






-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Jruby-user mailing list
Jruby-user@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/jruby-user




--
Charles Oliver Nutter @ headius.blogspot.com
JRuby Developer @ jruby.sourceforge.net
Application Architect @ www.ventera.com


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=k&kid3432&bid#0486&dat1642
_______________________________________________
Jruby-user mailing list
Jruby-user@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/jruby-user








-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Jruby-user mailing list
Jruby-user@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/jruby-user




--
Charles Oliver Nutter @ headius.blogspot.com
JRuby Developer @ jruby.sourceforge.net
Application Architect @ www.ventera.com


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=k&kid3432&bid#0486&dat1642
_______________________________________________
Jruby-user mailing list
Jruby-user@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/jruby-user








-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise