Case in point, this morning I was writing a unit test in Java, and needed to use two dates in my test code, one that was further in the future than the other. In Java, this looks something like this:
Date now = new Date();
Calendar calendar = new GregorianCalendar();
Date oneHourFromNow = calendar.getTime();
I know I don't need to explicitly set the calendar to 'now', however, I use the 'now' reference in the tests, so it seemed to be slightly more correct and explicit to do so. Further, the only reason for this setup code is to use the now and oneHourFromNow references in my tests.
In Rails, I would simply reference:
when I wanted to get the current time, and then use the nice time-related functions that Rails adds:
Time.now + 1.hour
when I needed a time that was in the future. If I wanted the exact same semantics as the Java code, I suppose I could do this:
now = Time.now
one_hour_from_now = Time.now + 1.hour
but that doesn't seem to add much in the way of comprehensibility, so I'd likely skip that altogether.
So, in reality, what would take me five lines of code in Java, essentially takes zero in Rails, which, as I calculate things, is infinitely better.