Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Compiled version of Ruby

0 views
Skip to first unread message

zero

unread,
Nov 2, 2005, 4:07:08 PM11/2/05
to
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

gregarican

unread,
Nov 2, 2005, 4:16:36 PM11/2/05
to
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 http://www.atdot.net/yarv/ for details...

James Edward Gray II

unread,
Nov 2, 2005, 4:21:09 PM11/2/05
to
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.

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

Kevin Brown

unread,
Nov 2, 2005, 4:22:21 PM11/2/05
to
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.


men...@rydia.net

unread,
Nov 2, 2005, 4:22:37 PM11/2/05
to
Quoting zero <web...@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


gabriele renzi

unread,
Nov 3, 2005, 6:00:01 AM11/3/05
to
Kevin Brown ha scritto:
notice that is planned for yarv to even support translation to C, and
that some basic functionality for this is already available

zero

unread,
Nov 3, 2005, 1:17:37 PM11/3/05
to
"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

Eric Hodel

unread,
Nov 3, 2005, 3:02:00 PM11/3/05
to
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.

ZenObfuscator can compile a Ruby program to C.

It has not been released.

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


Stefan Lang

unread,
Nov 3, 2005, 3:16:03 PM11/3/05
to

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


gabriele renzi

unread,
Nov 3, 2005, 5:04:59 PM11/3/05
to
Stefan Lang ha scritto:

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.


Garance A Drosehn

unread,
Nov 3, 2005, 10:10:55 PM11/3/05
to
On 11/2/05, zero <web...@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>.

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)

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


Dean Wampler

unread,
Nov 4, 2005, 10:52:19 AM11/4/05
to
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?


--
Dean Wampler
http://www.aspectprogramming.com
http://www.newaspects.com
http://www.contract4j.org


gabriele renzi

unread,
Nov 4, 2005, 6:38:18 PM11/4/05
to
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.

0 new messages