While this is a trivial example, I think it demonstrates something useful in the whole "less is more" arena: If you can write less code, there are just fewer opportunities for bugs. Having said that, note the tongue in cheek nature of the challenge:
The kiloseconds project is a very sophisticated and exquisite, ego-boosting and mind-blowing (albeit perhaps a bit over-engineered) project which aims to provide its audience with the time in kiloseconds, since we cannot live without it.
The Ruby example is nearly as short as the Smalltalk one, but still manages to be a bit more complex. Then there are things like the Java example :)
import java.util.GregorianCalendar;
public class Kiloseconds {
public static void main(String[] args) {
GregorianCalendar calendar = new GregorianCalendar();
int hours, minutes, seconds, kiloseconds;
hours = calendar.get(GregorianCalendar.HOUR_OF_DAY);
minutes = calendar.get(GregorianCalendar.MINUTE);
seconds = calendar.get(GregorianCalendar.SECOND);
kiloseconds = (hours*3600 + minutes*60 + seconds) / 1000;
System.out.println(kiloseconds + "\n");
}
}
The Smalltalk example?
'It is ', (Time now asSeconds/1000.000) printString, ' kiloseconds'
Trivial yes, but it does make a useful point...