The Passionate Craftsman

Ruby, PHP, MySql, Software engineering and more.

Saturday, 27 June 2009

merb new Ruby framework

merb is a new framework for Ruby. Why we need merb if we have Rails? merb has data mapper as default ORM tool, which is more powerful than ActiveRecord when dealing with complex databases, plus is more modular and orientated to the enterprise. Matt Amionetti has mad a presentation at QCon, in San Francisco, which is highly suggested if you are interested in merb.

I tried to install merb but the installer crashes because a file is missing in the repository. I have to say than the documentation seems quite incomplete and the web site is quite poor in the design and contents.

However merb is a quite interesting framework, new enterprise ORM, RSec built-in, modular... I will have a look in the future, probably, now I will stick with Grails (built on top of Hibernate and Spring). For web development the better choices are Grails, Rails and now merb (although too young).

Merb: When Flexibility and Performance Matter
merb framework

Metaprogramming in Ruby

Dave Thomas is on infoq. He explain how metaprogramming in Ruby works. He explains many hidden and unknown features of the Ruby language, for instance the definition of a class can be changed in real time and is possible to define a method using a conditional statement. I have appreciated the the comments about Java, a programming language that was designed for mediocre programmer to commit less mistakes. In Ruby you have less restrictions and the talent is preferred instead of the fear that you have poor quality programmers in your team.



Firefox with full screen mode on Mac

Some of you should have noticed that Firefox on the mac does not has a full screen mode. There is a simple hack for that. Just install a Firefox plug-in, the you will have an icon in the bottom right of Firefox where you can switch to full or normal view mode.The plug-in is FullerScreen.



Thursday, 25 June 2009


I am sad to announce the PHP 5.3 has a new goto statement. From a paper of Dijkstra (1968) the goto statement has been considered harmful and so many year after PHP introduce a goto statement. I think that the spaghetti coders will be happy of using goto in their programs. But what about the credibility of PHP in the enterprise. Zend is claiming that PHP is a good technology for the enterprise environment, well, I do not think so.

Why do not why start to use GWBasic for web programming?


Edsger Dijkstra (March 1968). "Go To Statement Considered Harmful" (PDF). Communications of the ACM 11 (3): 147–148. doi:10.1145/362929.362947. "The unbridled use of the go to statement has as an immediate consequence that it becomes terribly hard to find a meaningful set of coordinates in which to describe the process progress. ... The go to statement as it stands is just too primitive, it is too much an invitation to make a mess of one's program.".

Sunday, 14 June 2009

Web Services

This week I have learnt so many things about web services. Eclipse and Axis2 are very useful to create, consume and register web services. The main protocol are SOAP, WDSL and UDDI. SOAP is use to exchange the messages, WDSL to describe a web service and UDDI is directory service used to register/publish web services. It is possible to access a web service using only UDDI, but this approach does not follow really the UDDDI standards. There is an alternative to UDDI, created and maintained by IBM, is known as WSIL, but UDDI is more well known. OASIS maintains UDDI.

Useful links:

UDDI on Wikipedia
Code Generator Wizard - eclipse Plug-in
Eclipse WTP Tutorials - Creating Bottom Up Web Service via Apache Axis2

Labels: , , , ,

The Origins of Linux - Linus Torvalds

In this video, a bit old, you can here the history of Linux for Linus Torvalds.

FreeBSD on a desktop

In the following video you can see FreeBSD on a desktop with Beryl.


Political election farce in Iran.

It is incredible what is happening in Iran. They tricked the elections. After 20 minutes the end of the voting time, they have declared that they won the election. This is a bad news for the world too. It is not a democracy, it is a dictatorship! It is a shame!


Friday, 12 June 2009

A video to understand what is the credit crunch

Labels: ,

Sunday, 7 June 2009

Learn limits online

I have found a website,, full of tutorials on mathematics. The author has published more than 300 videos on youtube. An example is the following video about limits.


Friday, 5 June 2009

Use Hazelcast library in PHP

If you want the power of Java in PHP, easily, the answer is Quercus / PHP. Quercus is a 100% implementation of PHP in Java. I have downloaed the GPL version of Resin, unzipped in C:\. The file to start the server is httpd.exe.

In "C:\resin-3.1.9\webapps\ROOT\WEB-INF" you will find "resin-web.xml", the configuration file of Resin. Copy the following text:


Than create this file "hello-world.php" in "C:\resin-3.1.9\webapps\ROOT" and copy this text:

echo "Hello World";

Now you should be able to see the script executed: http://localhost:8080/hello-world.php

Go to the Hazelcast web site and download the zip. Inside the zip copy "hazelcast.jar" in "C:\resin-3.1.9\webapps\ROOT\WEB-INF\lib", create the lib directory if does not exist.

Create another php file, say "htest.php". Copy the code:

import com.hazelcast.core.Hazelcast;
import java.util.Map;
import java.util.Collection;
require_once './Customer.php';

$mapCustomers = Hazelcast::getMap("customers");
$mapCustomers->put("1", new Customer("Joe", "Smith"));
$mapCustomers->put("2", new Customer("Ali", "Selam"));
$mapCustomers->put("3", new Customer("Avi", "Noyan"));

$colCustomers = $mapCustomers->values();
foreach ($mapCustomers as $cus) {
echo $cus->getName().'

In "htest.php" you call the Hazelcast library, get an instance of a Map, a distributed Map! You put 3 new object into the map and than you print its property. To run this example you have to create the "Customer" class in PHP. In the same directory create "Customer.php" and copy this code:

class Customer {
protected $strName;

public function __construct($strName) {
$this->strName = $strName;

public function getName() {
return $this->strName;

Tahn run the example: http://localhost:8080/htest.php

You should get this output:



Hazelcast docs
Infoq: PHP on Java: Best of Both Worlds?
Use Java to Improve Drupal's Scalability

Performance of PHP platforms

I tested some different platforms to see which one has the best perfomance. I tested Zend Server CE, a SAMP environment and Resin with Quercus.

The Zend Server is running on my PC:

OS: Windows XP
Processor: P4 HT

This is the script that I used to test the performance:


This script is executed in 4.317 seconds on the Send Server CE.

The Resin Server Pro, with the compile option for better performance, executes the script in 12.72 seconds. The Resin Server with GPL license, without the compile option on, executes the script in 13.60 seconds. Both of versions of Resin are installed in my PC.

The SAMP server, is on a Solaris server, 32GB RAM and many CPUs. The execution time on Soalris is 36.79 seconds! On Solaris is used the Apache Handler and there is only eAccelerator, not APC.

My conclusion is that having a caching module on, it makes a big difference. Having Zend Server CE makes a huge difference. I do not think that Resin Pro is quite better than the GPL version, since the difference is very little.

In the end I would choose Resin Server with GPL license. A unique benefit is to have the integration of PHP with Java and the other dynamic languages, running on the JVM.

Labels: , , , ,