I currently use Ruby a lot but since I am not into developing web applications, I am not knowledgeable about Ruby on Rails. So when I watched Yehuda’s presentation about refactoring Rails I watched it not so much because of Rails but because of refactoring Ruby software.
Yehuda talks about introducing modules to be able to use super instead of alias_method_chain. I tried it out on an example and it seems to be a really useful thing to know.
Using alias_method_chain
This approach uses the popular definition of alias_method_chain
Overloading the method now can be done by including another module which has a new definition of x. The new method x can invoke the previous one by calling super
The issue with this approach is that overloading of the method needs to be anticipated. However at the same time the code indicates it more clearly that the first definition of x is not necessarily the final one in objects of type Test. Moreover this approach works without public definitions of methods you are not supposed to call (e.g.x_without_two).
Update: If you like to see another talk from MountainWest RubyConf 2009, you should check out Jim Weirich’s talk on The Building Blocks of Modularity.
Bad news for libertarians: Openmoko suspended development of the GTA03 smartphone until further notice and laid off part of its staff. The managing director said that this would be the only way for the company to survive in the long-term.
For the time being Openmoko abandons development work on the next generation of the current Freerunner smartphone. Furthermore the Taiwanese company releases almost half of its staff. This is what Openmoko managing director Sean Moss-Pultz said today at the Opensource trade show “Openexpo” in Bern. Partially the staff had been given notice; partially the staff had resigned voluntarily. “We have arrived at a critical point”, said Moss-Pultz. “This measures are absolutely necessary to even stay in business.”
Openmoko’s aim was ambitious: The subsidiary of the Taiwanese component manufacturer First International Computer (FIC) wanted to produce an Opensource-Smartphone. The source code was supposed to be freely available as well as the drivers and the specification of the components. Therefore software developers can reprogram the mobile phone at will. So far the company has produced two devices; the first one as a series of 3000 samples, the second one having been sold 10’000 times so far. Both are targeted at developers. The project was experiencing difficulties from the very beginning: The launch dates were postponed. Some batches had design faults. Furthermore there was a change in staff, which delayed development. At the middle of this year the software should have been stable enough for allowing the phone to be used in every day life.
Plan B
Openmoko now focusses on “Plan B” according to Sean Moss-Pultz. “For business reasons we have choosen the second device which we have in our pipeline.” He would not be free to disclose any more details. However it would not be about a telecommunication device. In contrast to the smartphone the first version is going to already target the mass market. Also this product is going to be developed with Opensource software he assured.
The development of the software for the Openmoko-Smartphone would continue said Moss-Pultz, however with less resources. Therefore he places great hope on the community. “Buy a Freerunner, help to fix the bugs and write new programs” he appealed to his audience during his presentation at the Openexpo. He hopes to also use those lateron on a new device. “Also in the future we want to produce mobile phones.” (Berner Zeitung)
I have made the presentation Ruby & Machine Vision available for download. The presentation gives an introduction to the Ruby programming language and its features. Furthermore it demonstrates a few capabilities of HornetsEye.
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 Array.map now returns an enumerator if you don’t give a code block as argument
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
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.
You can install Ruby 1.9 alongside 1.8 as follows (under GNU/Linux)
./configure --prefix=/usr/local --program-suffix=1.9
make
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