Language Expressiveness
Programming languages vary in their expressiveness. Why is expressiveness important? Because it’s closely related to abstraction. If I can code at a higher level of abstraction, I’m more productive and the code usually better expresses what it achieves. Example? Determine the date at 12 days and 5 hours in the future:
SMALLTALK: future := DateAndTime now + 12 days + 5 hours. JAVA: 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(…)).
Good old Smalltalk obviously wins. And it wins not just because the libraries are so well designed (I have to admit that the example is a bit unfair because the Java Calendar class really represents the bottom end of API design). It wins because expressiveness is build right into the language. Surprisingly, the Smalltalk language with its very few concepts is more expressive than Java that is way more complex, especially these days where Generics hit the ground. Here, the “everything is an object” metaphor together with dynamic typing makes the difference.