Friday, July 29, 2005

Expressive Smalltalk

This is why I really like Smalltalk (and it's dynamically typed companions).

Determine the date at 12 days and 5 hours in the future!
future := DateAndTime now + 12 days + 5 hours.
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
cal.add(Calendar.DAY_OF_MONTH, 12);
cal.add(Calendar.HOUR_OF_DAY, 5);
Date future = cal.getTime();
(Sun could at least make Calendar's add method return the Calendar itself so that we could daisy-chain the add calls like cal.add(...).add(...)).

Now tell me, which one is more expressive? This is exactly the advantage of the "everything is an object" principle. And maybe this expressiveness is the reason why in-language Domain Specific Languages ( are so much easier to implement in languages like Smalltalk than in this Java crap.


Post a Comment

<< Home