# Is there a real thing that can convert ruby scripts to c cod

**URL:** <https://www.ruby-forum.com/t/is-there-a-real-thing-that-can-convert-ruby-scripts-to-c-cod/112698>\
**Category:** Ruby\
**Created:** [August 22, 2007, 11:05am UTC](https://www.ruby-forum.com/t/is-there-a-real-thing-that-can-convert-ruby-scripts-to-c-cod/112698 "2007-08-22T11:05:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Magicloud\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e47774/32.png) [@Magicloud\_M](https://www.ruby-forum.com/u/Magicloud_M)\
**Post date:** [August 22, 2007, 11:05am UTC](https://www.ruby-forum.com/t/is-there-a-real-thing-that-can-convert-ruby-scripts-to-c-cod/112698/1 "2007-08-22T11:05:24Z")

</div>

Dear all,  
As I read ruby’s code, I think it is possible to convert ruby  
scripts to c codes. But I searched on [www.rubyforge.org](http://www.rubyforge.org), and got two  
tools which do not do real convertion. By real convertion, I mean to use  
c like “extend ruby with c”.  
The benifits, I think, are more easily interacting with libs writen  
by c, especially something like glib or qt. And more stable, e.g.  
rcairo, is very unstable.

Thanks.

---

<div class="post-metadata">

**Author:** ![Magicloud\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e47774/32.png) [@Magicloud\_M](https://www.ruby-forum.com/u/Magicloud_M)\
**Post date:** [August 22, 2007, 8:15pm UTC](https://www.ruby-forum.com/t/is-there-a-real-thing-that-can-convert-ruby-scripts-to-c-cod/112698/2 "2007-08-22T20:15:11Z")

</div>

Magicloud M. wrote:

> Dear all,  
> As I read ruby’s code, I think it is possible to convert ruby  
> scripts to c codes. But I searched on [www.rubyforge.org](http://www.rubyforge.org), and got two  
> tools which do not do real convertion. By real convertion, I mean to use  
> c like “extend ruby with c”.  
> The benifits, I think, are more easily interacting with libs writen  
> by c, especially something like glib or qt. And more stable, e.g.  
> rcairo, is very unstable.
> 
> Thanks.

I think that this would be an immense and thankless task. If you were  
to write code that was near C in syntax it might be easier.

e.g.

for i in 0…10 do  
puts ‘blah’  
end

but when it is

“5”.to\_i.times do  
puts ‘blah’ #note the different quotation marks used interchangably  
end

it is more cryptic. Add the oddities of hashing and the like and the  
task becomes HUGE and thankless.

In short, do not expect to see one anytime soon.

---

<div class="post-metadata">

**Author:** ![Magicloud\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e47774/32.png) [@Magicloud\_M](https://www.ruby-forum.com/u/Magicloud_M)\
**Post date:** [August 22, 2007, 8:47pm UTC](https://www.ruby-forum.com/t/is-there-a-real-thing-that-can-convert-ruby-scripts-to-c-cod/112698/3 "2007-08-22T20:47:07Z")

</div>

Magicloud M. wrote:

> Dear all,  
> As I read ruby’s code, I think it is possible to convert ruby  
> scripts to c codes. But I searched on [www.rubyforge.org](http://www.rubyforge.org), and got two  
> tools which do not do real convertion. By real convertion, I mean to use  
> c like “extend ruby with c”.  
> The benifits, I think, are more easily interacting with libs writen  
> by c, especially something like glib or qt. And more stable, e.g.  
> rcairo, is very unstable.

Do you mean something like this:

[http://www.onlamp.com/pub/a/onlamp/2004/11/18/extending\_ruby.html](http://www.onlamp.com/pub/a/onlamp/2004/11/18/extending_ruby.html)

or this:

[http://www.rubyinside.com/how-to-create-a-ruby-extension-in-c-in-under-5-minutes-100.html](http://www.rubyinside.com/how-to-create-a-ruby-extension-in-c-in-under-5-minutes-100.html)

I do not know how accurate this is - but maybe this gives you a start.

Stefan

---

<div class="post-metadata">

**Author:** ![Magicloud\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e47774/32.png) [@Magicloud\_M](https://www.ruby-forum.com/u/Magicloud_M)\
**Post date:** [August 22, 2007, 9:39pm UTC](https://www.ruby-forum.com/t/is-there-a-real-thing-that-can-convert-ruby-scripts-to-c-cod/112698/4 "2007-08-22T21:39:14Z")

</div>

Isn’t there ruby2c by zenspider?

---

<div class="post-metadata">

**Author:** ![Magicloud\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e47774/32.png) [@Magicloud\_M](https://www.ruby-forum.com/u/Magicloud_M)\
**Post date:** [August 23, 2007, 3:29am UTC](https://www.ruby-forum.com/t/is-there-a-real-thing-that-can-convert-ruby-scripts-to-c-cod/112698/5 "2007-08-23T03:29:36Z")

</div>

Kyle S. wrote:

> Isn’t there ruby2c by zenspider?

Yes, that is almost what I wanted, but RubyToC is not complete now, many  
things that does not support…
