Ruby 1.9 was released

Yesterday Ruby 1.9.1 was released. Here is a small presentation about changes in Ruby 1.9. There are some new features in the syntax and the semantics of local variables was improved. For example now returns an enumerator if you don’t give a code block as argument

e1 = [ 1, 2, 3, 4 ].collect
e2 = [ 5, 6, 7, 8 ].collect
loop { puts "#{}, #{}" }

Ruby 1.9 (formerly known as YARV) also has native threads. Now it is not necessary any more to use Distributed Ruby (DRb) to make use of multicore processors. Of course this means that a Ruby extension has to be thread-safe depending on how it is being used.

There also is a lot of work on making the handling of strings aware of the current character encoding

ruby -e "puts 'Hä?'.size"
# 4
ruby1.9 -e "puts 'Hä?'.size"
# 3
ruby -e "puts 'Hä?'[1]"
# 195
ruby1.9 -e "puts 'Hä?'[1]"
# ä

Another new feature is the implementation of fibers. Fibers are like threads but they are not preemptive. This means that a fiber has to suspend itself first before execution of the calling thread can continue. Fibers allow you to implement parallel contexts with implicit locking.

Yukihiro Matsumoto's keynote at Rubyconf 2007

You can install Ruby 1.9 alongside 1.8 as follows (under GNU/Linux)

./configure --prefix=/usr/local --program-suffix=1.9
sudo make install

The performance of the Ruby VM was improved and the memory footprint was reduced. String operations in general will be slower though since UTF-8 now is the default character encoding. But then again Yukihiro Matsumoto’s primary goal in designing Ruby always has been to minimize the effort in programming.

Note that it will take some time until the existing Ruby-extensions get ported to 1.9.

Update: I submitted a summary of this to Slashdot and it was accepted