[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Where's the bytecode from Ruby 1.9

James Dinkel

12/28/2007 3:18:00 PM

From what I understand, the big goal of YARV was to spit out bytecode
from your ruby scripts. From what I understand of bytecode, it can be
executed faster and also hides the source code. I may be
misunderstanding bytecode, but my question is can the just released Ruby
1.9.0 produce bytecode?
--
Posted via http://www.ruby-....

9 Answers

Paul Brannan

1/1/2008 2:55:00 PM

0

James Dinkel wrote:
>>From what I understand, the big goal of YARV was to spit out bytecode
> from your ruby scripts. From what I understand of bytecode, it can be
> executed faster and also hides the source code. I may be
> misunderstanding bytecode, but my question is can the just released Ruby
> 1.9.0 produce bytecode?

It uses a bytecode representation internally, but doesn't currently
write the bytecode to disk like python does.

The VM::InstructionSequence class gives some access to the bytecode.
You can get the individual elements of the sequence by calling #to_a.

There is support in Nodewrap for saving/restoring instruction sequences,
but needs to be updated for the latest 1.9.

Paul

James Dinkel

1/2/2008 2:35:00 PM

0

Paul Brannan wrote:
> It uses a bytecode representation internally, but doesn't currently
> write the bytecode to disk like python does.
>
> The VM::InstructionSequence class gives some access to the bytecode.
> You can get the individual elements of the sequence by calling #to_a.
>
> There is support in Nodewrap for saving/restoring instruction sequences,
> but needs to be updated for the latest 1.9.
>
> Paul

Thanks for the reply. There would be some startup-time savings if it
just converted to bytecode once, saved it to disk, and then could be
loaded straight from bytecode, right? Does anyone know if that
functionality is on the horizon? Of course there is a finite amount of
time in a day for the developers to work on ruby, so I have no problem
being patient. I just think ruby may get more business backing if it
can hide it's source code (for those who write closed-source software)
and would also keep people from making a "quick change" to production
code (ie introduce breakage to production code).

I would guess if it is already converting to bytecode internally than it
is getting some runtime performance benefits from it, and that's where I
personally would rather see the biggest speed improvements anyway.

James
--
Posted via http://www.ruby-....

Joseph Lenton

1/2/2008 7:25:00 PM

0

James Dinkel wrote:
> Thanks for the reply. There would be some startup-time savings if it
> just converted to bytecode once, saved it to disk, and then could be
> loaded straight from bytecode, right? Does anyone know if that
> functionality is on the horizon? Of course there is a finite amount of
> time in a day for the developers to work on ruby, so I have no problem
> being patient. I just think ruby may get more business backing if it
> can hide it's source code (for those who write closed-source software)
> and would also keep people from making a "quick change" to production
> code (ie introduce breakage to production code).
>
> I would guess if it is already converting to bytecode internally than it
> is getting some runtime performance benefits from it, and that's where I
> personally would rather see the biggest speed improvements anyway.
>
> James

I dunno about Python, but Java bytecode can be easily decompiled.

Joe.
--
Posted via http://www.ruby-....

Charles Oliver Nutter

1/3/2008 12:43:00 AM

0

Joseph Lenton wrote:
> James Dinkel wrote:
>> Thanks for the reply. There would be some startup-time savings if it
>> just converted to bytecode once, saved it to disk, and then could be
>> loaded straight from bytecode, right? Does anyone know if that
>> functionality is on the horizon? Of course there is a finite amount of
>> time in a day for the developers to work on ruby, so I have no problem
>> being patient. I just think ruby may get more business backing if it
>> can hide it's source code (for those who write closed-source software)
>> and would also keep people from making a "quick change" to production
>> code (ie introduce breakage to production code).
>>
>> I would guess if it is already converting to bytecode internally than it
>> is getting some runtime performance benefits from it, and that's where I
>> personally would rather see the biggest speed improvements anyway.
>>
>> James
>
> I dunno about Python, but Java bytecode can be easily decompiled.

In JRuby's case, we do support dumping bytecode to disk as Java .class
files. This would be roughly equivalent to Python's pyc files. And
although you can decompile Java bytecode, you'd end up decompiling it to
a mishmash of JRuby internal calls...it would be quite a bit harder to
decompile all the way to Ruby.

- Charlie

MonkeeSage

1/3/2008 2:13:00 AM

0

On Jan 2, 8:35 am, James Dinkel <jdin...@bucoks.com> wrote:
> Paul Brannan wrote:
> > It uses a bytecode representation internally, but doesn't currently
> > write the bytecode to disk like python does.
>
> > The VM::InstructionSequence class gives some access to the bytecode.
> > You can get the individual elements of the sequence by calling #to_a.
>
> > There is support in Nodewrap for saving/restoring instruction sequences,
> > but needs to be updated for the latest 1.9.
>
> > Paul
>
> Thanks for the reply. There would be some startup-time savings if it
> just converted to bytecode once, saved it to disk, and then could be
> loaded straight from bytecode, right? Does anyone know if that
> functionality is on the horizon? Of course there is a finite amount of
> time in a day for the developers to work on ruby, so I have no problem
> being patient. I just think ruby may get more business backing if it
> can hide it's source code (for those who write closed-source software)
> and would also keep people from making a "quick change" to production
> code (ie introduce breakage to production code).
>
> I would guess if it is already converting to bytecode internally than it
> is getting some runtime performance benefits from it, and that's where I
> personally would rather see the biggest speed improvements anyway.
>
> James
> --
> Posted viahttp://www.ruby-....

IIRC, before YARV was merged, it had an option to save / load bytecode
to / from files. But it's been a year or two and my memory is kind of
cloudy. Maybe it was a test or example ruby script that did it rather
than YARV core...hmm...can't recall. But if so (either from core or
from exposed API), then it seems like a good bet that KRI will be able
to do that someday (and like Charlie said, JRuby is already adding
support, which will presumably be made binary-compatible with a dump
from KRI if / when it's implemented).

Regards,
Jordan

James Dinkel

1/3/2008 4:27:00 PM

0

Charles Oliver Nutter wrote:
>
> In JRuby's case, we do support dumping bytecode to disk as Java .class
> files. This would be roughly equivalent to Python's pyc files. And
> although you can decompile Java bytecode, you'd end up decompiling it to
> a mishmash of JRuby internal calls...it would be quite a bit harder to
> decompile all the way to Ruby.
>
> - Charlie

Waitaminute. So if I have a paid-for application from some company and
they wrote it in java, it would be possible for me to decompile it into
the sourcecode? I figured there must be some way to hide it, otherwise
proprietary software wouldn't use it?
--
Posted via http://www.ruby-....

Rick DeNatale

1/3/2008 5:38:00 PM

0

On Jan 3, 2008 11:26 AM, James Dinkel <jdinkel@bucoks.com> wrote:
> Charles Oliver Nutter wrote:
> >
> > In JRuby's case, we do support dumping bytecode to disk as Java .class
> > files. This would be roughly equivalent to Python's pyc files. And
> > although you can decompile Java bytecode, you'd end up decompiling it to
> > a mishmash of JRuby internal calls...it would be quite a bit harder to
> > decompile all the way to Ruby.
> >
> > - Charlie
>
> Waitaminute. So if I have a paid-for application from some company and
> they wrote it in java, it would be possible for me to decompile it into
> the sourcecode?

Yep, try googling "java decompiler"
--
Rick DeNatale

My blog on Ruby
http://talklikeaduck.denh...

Florian Frank

1/4/2008 1:16:00 AM

0

James Dinkel wrote:
> Waitaminute. So if I have a paid-for application from some company and
> they wrote it in java, it would be possible for me to decompile it into
> the sourcecode?

Yes, it's also a lot of fun to do that.

> I figured there must be some way to hide it, otherwise
> proprietary software wouldn't use it?

Not, really. There are obfuscators available, that rename classes,
methods, etc. but this merely increases the challenge a bit.

--
Florian Frank

James Dinkel

1/4/2008 4:52:00 PM

0

Florian Frank wrote:
> James Dinkel wrote:
>> Waitaminute. So if I have a paid-for application from some company and
>> they wrote it in java, it would be possible for me to decompile it into
>> the sourcecode?
>
> Yes, it's also a lot of fun to do that.
>
>> I figured there must be some way to hide it, otherwise
>> proprietary software wouldn't use it?
>
> Not, really. There are obfuscators available, that rename classes,
> methods, etc. but this merely increases the challenge a bit.

Thanks everyone for the info. So when the Rubinius website says this:

"The Rubinius compiler generates bytecode that you can distribute in
easy-to-install packages similar to jar files. Other measures to protect
intellectual property can be easily added."

I take it they are just talking about the same thing... bytecode with
obfuscators and such.
--
Posted via http://www.ruby-....