ruby2c?

R

Roger Pack

I tried to get ruby2c working recently and none of the files in the
demos folder seem to translate, and requiring ruby_to_ansi_c file
doesn't seem to work, either.

Anybody gotten this bad boy to work?

-=r
 
R

Roger Pack

I tried to get ruby2c working recently and none of the files in the
demos folder seem to translate, and requiring ruby_to_ansi_c file
doesn't seem to work, either.

Anybody gotten this bad boy to work?

Anyone know of any libraries out that convert bottlenecks in ruby to C?
Or anything working that's ruby to c?
Thanks!
-=r
 
K

Kyle Schmitt

I did eventually get it working once, but I forget how I did it (and
that box is gone now, so I can't easily look it up). I also got
ruby2cext working, which was a lot easier. For what I wanted, ruby2c
wasn't worth the headache.

I recall two things about ruby2c though:
1) it translates the ruby in your code to C, but not any included code
or libs. At least that's all it did for me. The end result was I
could only translate rather simple methods, or small pieces of code to
C, not whole programs.
2) it only worked in 1.8.x

ruby2cext (http://ruby2cext.rubyforge.org/) was fairly easy to get
going, even with rather complex programs/libraries. The resulting
code has to be run in ruby (just load it as a library I think..), but
it worked pretty well.

--Kyle
 
R

Roger Pack

I recall two things about ruby2c though:
1) it translates the ruby in your code to C, but not any included code
or libs. At least that's all it did for me. The end result was I
could only translate rather simple methods, or small pieces of code to
C, not whole programs.
2) it only worked in 1.8.x

I did see some recent github commits to try and bring it up to 1.9
workability, but until I can actually get it to run...dunno.
ruby2cext (http://ruby2cext.rubyforge.org/) was fairly easy to get
going, even with rather complex programs/libraries. The resulting
code has to be run in ruby (just load it as a library I think..), but
it worked pretty well.

Wow ruby2cext looks fascinating. It can even inline calls to core
classes, like
def go
"".center 3
end

gets translated to ruby C
VALUE go_c(VALUE self) {
return
(*(string_center_which_we_already_looked_up_at_load_time))(NUM2INT(3));
}

i.e. it avoids unnecessary function calls (if you pass it -O
builtin_methods).
Thanks!
-=r
 

Ask a Question

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.

Ask a Question

Members online

Forum statistics

Threads
474,172
Messages
2,570,934
Members
47,477
Latest member
ColumbusMa

Latest Threads

Top