Archive for October 11th, 2007

Guillaume Laforge, the leader (and probably the guy who rescued this project!) of the Groovy language project has just launched his own company called G2One Inc..

Guess what?… they are focusing on Groovy and Grails :-)

I wish them all the best!

Comments No Comments »

Today I had fun playing with Rinda, the Ruby implementation of the Linda distributed process coordination paradigm. I also had some time for blogging, something that I haven’t done for a few days because of too much work (and there still a bunch left to be done :-) )

I won’t go through the theory behind Linda, but the gross idea is to use a shared memory space that implements the distributed blackboard paradigm : the Tuple Space. It can be summarized on the following figure:

tuplespace.png

Data is represented as sets of tuples which often have a limited lifetime. The tuple space provides the distributed processes the following primitives:

  • write: writes a tuple to the tuple space
  • read: reads a tuple from the tuple space
  • take: reads and removes a tuple from the tuple space

The beauty of the model lies in the fact that the tuple space guarantees atomic operations and periodically cleans up old tuples. Also, reading operations match a tuple on:

  1. the length of the requested and available tuples
  2. the matching (exact value, regular expressions, …) of certain elements of the tuple.

I have put together a first Ruby program that reads text from the console, and writes tuples whenever a line is entered. The other program takes every new tuple that is emitted.

emitter.rb

#!/usr/bin/env ruby
 
require 'drb/drb'
require 'rinda/ring'
require 'rinda/tuplespace'
 
DRb.start_service
 
tuple_space = Rinda::TupleSpace.new
ring_server = Rinda::RingServer.new tuple_space
 
while true
  tuple_space.write [:message, gets]
end

receiver.rb

#!/usr/bin/env ruby
 
require 'drb/drb'
require 'rinda/ring'
require 'rinda/tuplespace'
 
DRb.start_service
 
tuple_space = Rinda::RingFinger.primary
 
while true
  puts tuple_space.take([:message, nil])[1]
end

What I really like is the simplicity of the code, thanks to the cleanness of Linda and the elegance of Ruby :-) The other thing is that DRb is such a straightforward way to use distributed objects in Ruby…

BTW there is a Java implementation of this paradigm called JavaSpaces.

Comments No Comments »