Convert Ruby to low level languages?

Viewed 14527

I have all kind of scripting with Ruby:

rails (symfony)
ruby (php, bash)
rb-appscript (applescript)

Is it possible to replace low level languages with Ruby too?

I write in Ruby and it converts it to java, c++ or c.

Cause People say that when it comes to more performance critical tasks in Ruby, you could extend it with C. But the word extend means that you write C files that you just call in your Ruby code. I wonder, could I instead use Ruby and convert it to C source code which will be compiled to machine code. Then I could "extend" it with C but in Ruby code.

That is what this post is about. Write everything in Ruby but get the performance of C (or Java).

The second advantage is that you don't have to learn other languages.

Just like HipHop for PHP.

Are there implementations for this?

7 Answers

It is probably feasible to design a compiler that converts Ruby source code to C++. Ruby programs can be compiled to Python using the unholy compiler, so they could be compiled from Python to C++ using the Nuitka compiler.

The unholy compiler was developed more than a decade ago, but it might still work with current versions of Python.

Ruby2Cextension is another compiler that translates a subset of Ruby to C++, though it hasn't been updated since 2008.

Related