Forum: Ruby ruby2c?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Roger P. (Guest)
on 2009-06-02 08:45
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
Roger P. (Guest)
on 2009-06-03 08:29
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
Kyle S. (Guest)
on 2009-06-03 20:29
(Received via mailing list)
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
Roger P. (Guest)
on 2009-06-06 22:53
> 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
This topic is locked and can not be replied to.