Goodbye to Java
I have been working with PHP for a long time now, and Java for longer, and Ruby for about a week. Today, I had to implement a very small script in a jsp page without my library of helper functions. This script in php would have been easy in about 10 lines. In Ruby, 5 lines. In java, it was about 35. I just had to post the most obvious example of Java obtuseness:
public int compare(Object left, Object right) {
return ((Long)((HashMap)left)
.get("timestamp")).compareTo((Long)((HashMap)right)
.get("timestamp"));
}
The context is trying to sort an array of hashes according to one of the entries which was a long. Sounds simple right? Not in java.
When I first started writing PHP scripts, I cursed the fact that there was no typing and I always got mixed up in what was what. But now, I really see the benefits of a loosely typed language!