From: William Djaja Tjokroaminata Date: 2002-09-24T05:19:11+09:00 Subject: Re: Using Ruby with other languages Hi, Tapio Kelloniemi wrote: > I would like to know, whether it is possible to compile Ruby code to > executables so I could run Ruby code without the interpreter. If you mean to a stand-alone executable, not currently. Python generates some object code (byte code?), but I think it still needs the Python interpreter. To me this is an interesting question, whether even some small, limited Ruby to C translator can be written. Based on my initial experience writing Ruby in C, my feeling says yes, but probably it is wrong. > I also > would like to do this, when I noticed that a simple Ruby program runs > more than 100 times slower than identically implemented C program. Currently there is some initial release of Ruby "inline" that can be used to insert C code in the middle of Ruby code to speed up the critical parts. Creating a Ruby/C code that is as fast as a (comparable algorithmically) C code is impossible, I think, because Ruby is garbage-collected language and there is some overhead required by the Ruby object model. > I > also would like to know, wheter it is possible to compile RUby code to > object format and then link with code written in different languages, > EG. C++ and C. As Ruby itself is written in C, linking to other code or library in C or C++ has been done all the time; however, currently you need to learn some Ruby C API to do that, or browse the SWIG web site (www.swig.org). Regards, Bill