N
n/a
Hi,
Complete newbie here; is there anything in the works as far as a compiler
for Ruby?
Thanks.
Complete newbie here; is there anything in the works as far as a compiler
for Ruby?
Thanks.
http://www.catb.org/~esr/faqs/smart-questions.htmln/a said:Hi,
Complete newbie here; is there anything in the works as far as a compiler
for Ruby?
Thanks.
I meant under windows and/or Linux environments.
And source code to machine code.
I had done a search of this group but I guess didn't download enough
headers to see the previous threads.
I see there are various forms of compilers that work at different levels of
code, e.g. XRuby to Java Bytecode, etc.
I first encountered the idea of a "virtual machine" for reasons ofRick said:Yes there are a variety of approaches to compiling Ruby to either Java
bytecodes (e.g. XRuby) or bytecodes more specifically tuned to Ruby
semantics (e.g. YARV which is now in Ruby 1.9). I think most people
these days think that bytecode == Java bytecode, but the idea preceded
Java.
The prototype for a lot of this is (most implementations of) Forth.As of today YARV seems to be the best performing, at least according
to the benchmarks I've seen.
As for compiling directly to machine code, it could be done I suppose,
but it's not clear that it would be the best approach. Why?
* The dynamic nature of Ruby means that methods can be dynamically
created at run-time and would therefore need to be compiled at
run-time. Additional bookkeeping would be required to make all the
semantic effects on the compiled code would be properly implemented.
* Previous experience with compiling dynamic OO languages has shown
that the much smaller code representation of byte codes compared to
machine code can actually lead to better performance on machines with
virtual memory (almost all machines these days) due to the smaller
working set. Digitalk tried direct compilation of Smalltalk to
machine code, because they were sick of getting blasted for being
'interpreted' and found that the byte coded stuff ran significantly
faster. The practice these days is to do two-stage compilation, first
to byte-codes, and then to machine code for selected code when the
run-time detects that that code is frequently executed.
Np I guess your question was very nicely answered by a nice and
competent member I do not agree with Phil's welcome message.
Welcome to the group
Robert
Yes there are a variety of approaches to compiling Ruby to either Java
bytecodes (e.g. XRuby) or bytecodes more specifically tuned to Ruby
semantics (e.g. YARV which is now in Ruby 1.9). I think most people
these days think that bytecode == Java bytecode, but the idea preceded
Java.
As of today YARV seems to be the best performing, at least according
to the benchmarks I've seen.
As for compiling directly to machine code, it could be done I suppose,
but it's not clear that it would be the best approach. Why?
* The dynamic nature of Ruby means that methods can be dynamically
created at run-time and would therefore need to be compiled at
run-time. Additional bookkeeping would be required to make all the
semantic effects on the compiled code would be properly implemented.
* Previous experience with compiling dynamic OO languages has shown
that the much smaller code representation of byte codes compared to
machine code can actually lead to better performance on machines with
virtual memory (almost all machines these days) due to the smaller
working set. Digitalk tried direct compilation of Smalltalk to
machine code, because they were sick of getting blasted for being
'interpreted' and found that the byte coded stuff ran significantly
faster. The practice these days is to do two-stage compilation, first
to byte-codes, and then to machine code for selected code when the
run-time detects that that code is frequently executed.
Oh do not mention it if it had not been me somebody else would haveRobert,
It's not always easy being brand new to programming AND to Ruby so
a bit of a friendly attitude such as yours goes a long way, IMHO. And is
very much appreciated.
Rick said:* Previous experience with compiling dynamic OO languages has shown
that the much smaller code representation of byte codes compared to
machine code can actually lead to better performance on machines with
virtual memory (almost all machines these days) due to the smaller
working set.
You need a very carefully designed inner interpreter for this to beClifford said:Reducing the working set on boxes with GB of RAM typically
has more effect through decreasing cache spills than via
reductions in page faults. The byte-codes also go in
d-cache while the interpreter itself is in I-cache.
M. Edward (Ed) Borasky said:You need a very carefully designed inner interpreter for this to be
useful.
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.