Compiled version of Ruby

Z

zero

I know this has been discussed before but I would like to know if
anything has changed in the past 2 years and if anything is on the
horizon that would allow either byte compilation of Ruby (like Python)
or <dreaming> native compilation </dreaming>.

Ruby is cool, but I don't want to use it for anything I am likely to
install on a user's machine because (1) I often don't want users to
muck with my code, and (2) sometimes I don't want them to (easily) see
my code. I know that C#/Java can easily be reverse engineered, but
knowing that someone would have to go to such lengths to get to my code
is enough of a barrier to make me want to use one of those languages
over Ruby even though I have to write three times as much code for the
same task.

Don't get me wrong, I love Ruby, I'm not a troll. I'm porting a site
to Rails...so I have a strong predisposition to advocate Ruby for all
things server-side. I just want to be able to use Ruby in the space
where compiled languages tend to travel better than interpreted. I
want to use Ruby for everything and would if I could just get byte
compilation.

-
ed
 
G

gregarican

zero said:
I know this has been discussed before but I would like to know if
anything has changed in the past 2 years and if anything is on the
horizon that would allow either byte compilation of Ruby (like Python)
or <dreaming> native compilation </dreaming>.

Have you checked out YARV? See http://www.atdot.net/yarv/ for details...
 
J

James Edward Gray II

Ruby is cool, but I don't want to use it for anything I am likely to
install on a user's machine because (1) I often don't want users to
muck with my code, and (2) sometimes I don't want them to (easily) see
my code. I know that C#/Java can easily be reverse engineered, but
knowing that someone would have to go to such lengths to get to my
code
is enough of a barrier to make me want to use one of those languages
over Ruby even though I have to write three times as much code for the
same task.

I know this isn't exactly what you asked for, but if you just need a
minor deterrent, perhaps a hack along the lines of http://
www.rubyquiz.com/quiz34.html would work. Just a thought.

James Edward Gray II
 
G

gabriele renzi

Kevin Brown ha scritto:
Ruby 2.0 will be byte compiled. Take a look at YARV.

http://www.atdot.net/yarv/

This will be the VM for Ruby 2.0, Matz has already declared.
notice that is planned for yarv to even support translation to C, and
that some basic functionality for this is already available
 
Z

zero

"notice that is planned for yarv to even support translation to C, and
that some basic functionality for this is already available"

OK, things are heating up.

It sounds like the Gabmit Scheme approach. Will 'yarv' output ansi C
which we can then run through a C compiler of our choice?

Are there any gcc front ends planned?

Thanks for your post, this is fantastic news.

-
e
 
E

Eric Hodel

I know this has been discussed before but I would like to know if
anything has changed in the past 2 years and if anything is on the
horizon that would allow either byte compilation of Ruby (like Python)
or <dreaming> native compilation </dreaming>.

Ruby is cool, but I don't want to use it for anything I am likely to
install on a user's machine because (1) I often don't want users to
muck with my code, and (2) sometimes I don't want them to (easily) see
my code. I know that C#/Java can easily be reverse engineered, but
knowing that someone would have to go to such lengths to get to my
code
is enough of a barrier to make me want to use one of those languages
over Ruby even though I have to write three times as much code for the
same task.

ZenObfuscator can compile a Ruby program to C.

It has not been released.
 
S

Stefan Lang

"notice that is planned for yarv to even support translation to C,
and that some basic functionality for this is already available"

OK, things are heating up.

It sounds like the Gabmit Scheme approach. Will 'yarv' output ansi
C which we can then run through a C compiler of our choice?

Are there any gcc front ends planned?

Thanks for your post, this is fantastic news.

I wouldn't be to euphoric. I don't think it will be ever possible
to convert a Ruby program to C code that doesn't depend on a Ruby
interpreter.
Extreme example: eval

If it would be possible, Ruby were just C with different syntax.

Regards,
Stefan
 
G

gabriele renzi

Stefan Lang ha scritto:
I wouldn't be to euphoric. I don't think it will be ever possible
to convert a Ruby program to C code that doesn't depend on a Ruby
interpreter.
Extreme example: eval
If it would be possible, Ruby were just C with different syntax.

yes, AFAIK, the ruby->c translation just spits out a C library that you
can use in your code to get a great speedup (and some obfuscation).

Anyway, I think it would be possible to avoid depending on an
interpreter, following the same approach other compilers for dynamic
languages do: depend on a library (just like libruby) and compile it
directly in the executable.
 
G

Garance A Drosehn

I know this has been discussed before but I would like to know if
anything has changed in the past 2 years and if anything is on the
horizon that would allow either byte compilation of Ruby (like Python)
or <dreaming> native compilation </dreaming>.

You might want to check out the 'ruby2c' project. It is still in beta-land=
,
but with it you could at least translate some ruby that you write into C
code, and then run that in combination with standard ruby.

http://rubyforge.org/projects/ruby2c/

(disclaimer: I have not tried ruby2c, I just think it is an interesting and
worthwhile project)
 
D

Dean Wampler

Bruce Tate in his book "Beyond Java" argues that Ruby would benefit a
lot if it ran on top of the Java VM, e.g., the JRuby project. The
benefits would include years of effort to optimize performance and
easy access to Java libraries. On the other hand, a Ruby-specific VM
could be tuned for the specifics of the language.

Has anyone analyzed the pros and cons of these two approaches?
 
G

gabriele renzi

Dean Wampler ha scritto:
Bruce Tate in his book "Beyond Java" argues that Ruby would benefit a
lot if it ran on top of the Java VM, e.g., the JRuby project. The
benefits would include years of effort to optimize performance and
easy access to Java libraries. On the other hand, a Ruby-specific VM
could be tuned for the specifics of the language.

Has anyone analyzed the pros and cons of these two approaches?

I think that there asre still issues for a ruby interpreter running on
top of the jvm (I'm thinking of HotSpot here) or any other VM designed
for static languages, since some ruby features would run suboptimally on
it.

Think for example of IronPython: it runs faster than CPython on the .net
VM (CLR,which is similar to the jvm) for some benchmarks, and this is a
great goal.
But it is still tens of times slower than C# on the same runtime, since
the VM does not provide mechanisms aimed at optimizing a language like
python (or ruby).

Anyway it is worth noting that SUN seem to be thinking of fixing some of
the issues, see for example the news about a new opcode "invokedynamic"
which is specifically thought to speed up dispatch in dynamically typed
languages.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,740
Latest member
JudsonFrie

Latest Threads

Top