my love for Java

Posted by crayz

Reading through some basic Sun language docs, I remember why I hated C++:

class SwitchDemo2 {
    public static void main(String[] args) {

        int month = 2;
        int year = 2000;
        int numDays = 0;

        switch (month) {
            case 1:
            case 3:
            case 5:
            case 7:
            case 8:
            case 10:
            case 12:
                numDays = 31;
                break;
            case 4:
            case 6:
            case 9:
            case 11:
                numDays = 30;
                break;
            case 2:
                if ( ((year % 4 == 0) && !(year % 100 == 0))
                     || (year % 400 == 0) )
                    numDays = 29;
                else
                    numDays = 28;
                break;
            default:
                System.out.println("Invalid month.");
                break;
        }
        System.out.println("Number of Days = " + numDays);
    }
}

Or Ruby:

month, year = 3, 2000

days = case month
  when 1, 3, 5, 7, 8, 10, 12  then 31
  when 4, 6, 9, 11            then 30
  when 2 then
    if ((year % 4).zero? && (year % 100 != 0)) || (year % 400).zero?
      29
    else
      28
    end
  else raise "Invalid Month"
end

puts "Number of Days = #{days}"

You've gotta love Java having to wrap everything in a class though... It feels so "object oriented"

"Apple loves Java", part 2

Posted by crayz

Heh, reminiscing back to that wonderfully hilarious statement that "Apple loves Java." They have shown how much they love it with their new Mac OS X 10.5, Leopard. On the page of 300 new features, number of sections in which the following technologies are mentioned
JavaScript: 3
Python: 4
Ruby: 5
Java: 0

Leopard has added the latest versions of Ruby, Rails, Mongrel, and a number of other gems included by default. They worked closely with the Ruby community to make this possible. Java... still at Java 5. Java 6, released nearly a year ago, will be added as a separate download at some undetermined later date. Can you feel the love?

Update: More here, here, and here. Funny stuff