From: Bulat Ziganshin Date: 2002-09-24T15:16:42+09:00 Subject: Re: Using Ruby with other languages Hello Tapio, Monday, September 23, 2002, 10:38:37 PM, you wrote: TK> I'm new to Ruby, but before seriously studying the language I would like TK> to get some information. TK> I would like to know, whether it is possible to compile Ruby code to TK> executables so I could run Ruby code without the interpreter. I also TK> would like to do this, when I noticed that a simple Ruby program runs TK> more than 100 times slower than identically implemented C program. I TK> also would like to know, wheter it is possible to compile RUby code to TK> object format and then link with code written in different languages, TK> EG. C++ and C. 1. are you know difference between compilation and interpretation? are you know assembler? are you ever seen internals of any interpreter? on simplest code i see 1000 times difference between C and Ruby. i.e. to execute one simple Ruby instruction, interpreter had to execute 1000 lines of C code. this leads to 1 million of simple Ruby instructions per second - enough performance for 90% of code for commercial program and more than enough for almost any in-house scripting this is argument for me to switch to interpreted languages (considering that ruby reduces development time). but if you want to be absolutely fast, see at c++ or eiffel 2. there is many solutions to combine c and ruby (and other languages) code: a) you can write libraries for Ruby in C and link its dynamically or statically in interpreter itself. see readme.ext in distribution b) you can inline C code in ruby programs (see RubyInline on yaraa) c) you can translate Ruby code to C (see rb2c). this don't speed up your program, but helps to make single executable d) you can use exerb, which adds Ruby code inside single executable in another way -- Best regards, Bulat mailto:bulatz@integ.ru