Compiled version of Ruby

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

zero wrote:

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 YARV: Yet Another Ruby VM for details...

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 Ruby Quiz - Whiteout (#34) would work. Just a thought.

James Edward Gray II

···

On Nov 2, 2005, at 3:12 PM, zero wrote:

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.

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.

···

On Wednesday 02 November 2005 15:12, zero wrote:

I
want to use Ruby for everything and would if I could just get byte
compilation.

Quoting zero <web2ed@gmail.com>:

There's always rubyscript2exe:

http://www.erikveen.dds.nl/rubyscript2exe/index.html

It's not a "real compiler", but it bundles up everything into a
single executable which is certainly more convenient to deploy.

-mental

ZenObfuscator can compile a Ruby program to C.

It has not been released.

···

On Nov 2, 2005, at 1:12 PM, zero wrote:

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.

--
Eric Hodel - drbrain@segment7.net - http://segment7.net
FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04

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)

···

On 11/2/05, zero <web2ed@gmail.com> wrote:

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>.

--
Garance Alistair Drosehn = drosihn@gmail.com
Senior Systems Programmer or gad@FreeBSD.org
Rensselaer Polytechnic Institute; Troy, NY; USA

Kevin Brown ha scritto:

···

On Wednesday 02 November 2005 15:12, zero wrote:

I
want to use Ruby for everything and would if I could just get byte
compilation.

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

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?

···

On 11/2/05, Kevin Brown <blargity@gmail.com> wrote:

On Wednesday 02 November 2005 15:12, zero wrote:
> I
> want to use Ruby for everything and would if I could just get byte
> compilation.

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.

--
Dean Wampler
http://www.aspectprogramming.com

http://www.contract4j.org

"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

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.

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

···

On Thursday 03 November 2005 19:22, zero wrote:

"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.

Stefan Lang ha scritto:

···

On Thursday 03 November 2005 19:22, zero wrote:

"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.

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.