Ruby2CExtension is a Ruby to C extension translator/compiler. It takes any Ruby source file, parses it using Ruby's builtin parser and then translates the abstract syntax tree into "equivalent" C extension code. More information and download at http://ruby2cext.rubyforge.org/. Example ------- Let's say you have a Ruby file foo.rb. To translate it to a C extension and then compile it, just run: rb2cx foo.rb This will produce the files foo.c and foo.so (on Linux). foo.c is the generated C extension source code and foo.so is the compiled C extension. Why? ---- Well, like everybody else I wanted a faster Ruby and I also wanted to learn about Ruby's internals, so I thought translating Ruby to C might be worth a try... The results are not as good as I had hoped, but they aren't bad either: the generated C extension is practically never slower than the Ruby code and I found cases where it is more than twice as fast, usually it is somewhere in between. Of course Ruby2CExtension can also be used as an obfuscator for Ruby code, though this was not my main motivation. Features -------- Ruby2CExtension supports a very large subset of Ruby's features (it can translate itself into a C extension and the compiled version works correctly): * all the basics (classes, methods, ...) * blocks, closures * instance_eval, define_method, ... (only when the block is given directly) * correct constant and class variable lookup * raise, rescue, retry, ensure * ... Of course there are some limitations, please see http://ruby2cext.rubyforge.org/limitations.html Requirements ------------ * Ruby 1.8.4 * RubyNode (http://rubynode.rubyforge.org/)