Where's the bytecode from Ruby 1.9

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?

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

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

Joseph L. wrote:

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

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

On Jan 2, 8:35 am, James D. [email protected] wrote:

Paul

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-forum.com/.

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

On Jan 3, 2008 11:26 AM, James D. [email protected] 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?

Yep, try googling “java decompiler”

Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/

Charles Oliver N. 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?

James D. 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 F. wrote:

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