Starting with Rubinius & Problems
Yesterday, I was reading my timeline on twitter when I saw a tweet - precisely, this one - which made me curious about it.
So, I went to Rubinius page and download the package for Mac OSX (yep, I'm using OSX, but you can use it on Linux too... unless you're using Windows. In this case, I highly recommend to you: use a Linux distro.
Well, installed the .pkg (package format for OSX) and tested it on terminal:
Will print something like:
rubinius 1.2.4 (1.8.7 release 2011-07-05 JI) [x86_64-apple-darwin10.7.4]
It's easy and recommend install rubinius through RVM. Seriously. Of course, If you pretend to use different ruby versions on your computer.
To install through rvm you have to - of course - install RVM (installation guide here) first and then run the following in your terminal:
And to use it (if you aren't familiar with the RVM premise, go google about it):
Which will output something like this
Using /Users/{your_user_name}/.rvm/gems/rbx-master
Rubinius uses the 1.8.7 dev version of Ruby
Some Rails versions won't work with him.
Ok, let's take an test case for rubinius (just compile a .rb file doesn't show his potential):
Rails app: I'm working in an app for a customer right here in Brazil. Here is the gemfile configuration:
As in Development mode, I'm using SQLite3
Uses HAML and SASS for templating
Other ~gems~ like Devise, Simple_form, Bourbon, and many others.
To use Rubinius in this app, I had to do the following:
rvm use rbx bundle install
(P.S.: bundle install to install the gems under Rubinius gemset)
And then, run the app, normally:
If you see an error when starting the rails server command, check if you're using a .rvmrc in the app root folder. Switch the ruby's version to 1.8.7 (rmv use system) if necessary.
When I switched to browser (accessing http://host:port), an error occured:
TemplateError: Cannot modify SafeBuffer in place
Perhaps an error in HAML version? In earlier versions (<~ 3.1.2), HAML was using gsub! instead of gsub and that was the main cause which throws this kind of error. But no, isn't HAML. Update to Rails 3.1 and your problem is solved.
WOW. My application now is running pretty fast, almost "instantly" to load all the pages
Rubinius compiles bytecode to machine code. You'll see some *.rbc files in your project tree. They are the compiled files.
Of course, I tested only in Rails to see the improvements in using a Virtual Machine to run my application and I'll test in other type of apps soon.