How to Install Rubinius

Rubinius is an alternative implementation of Ruby.

  1. Install Git
  2. Copy Rubinius repository
  3. Build by ‘rake build’
  4. Install by ‘rake install’
  5. Invoke Rubinius by ‘rbx’

### Install Git
$ sudo port install git-core
$ git config --global user.name "My Name"
$ git config --global user.email "my@email"
### Copy Rubinius repository
$ git clone git://git.rubini.us/code rubinius.code
$ cd rubinius.code
### Build Rubinius
$ more INSTALL
$ gem install rake    # if you have not installed rake yet
$ rake build
### Install Rubinius
$ sudo rake install
### Invoke Rubinius
$ /usr/local/bin/rbx -v

The following is a tiny benchmark.

$ ruby -v
ruby 1.8.6 (2007-03-13 patchlevel 0) [i686-darwin8.9.1]
$ time ruby -e 'def f(n); n<=1 ? 1 : f(n-1)+f(n-2); end; p f(33)'
5702887

real    0m13.683s
user    0m13.615s
sys     0m0.031s

$ rbx -v -e 'nil'
rubinius 0.8.0 (ruby 1.8.6 compatible) (ecf1b9d19) (12/05/2007) [i686-apple-darwin8.11.1]
$ time rbx -e 'def f(n); n<=1 ? 1 : f(n-1)+f(n-2); end; p f(33)'
5702887

real    0m16.625s
user    0m16.468s
sys     0m0.103s

The result shows that Rubinius is a little slower than MRI.

Leave a reply