China Musings

Writings and Ramblings (A/V) from Guangzhou, China

Goodbye to Java

Filed under: Work Related, Web Development — Adeh at 6:13 pm on Wednesday, April 12, 2006

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!

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong> <img src="">