Language Expressiveness and Complexity
Recently I've seen
comments about how language complexity is a Bad Thing that Must Be Avoided. I disagree. The expressiveness of a language influences what you can say with it. This applies to natural languages, programming languages, even programming APIs! When the language gets more complex (by adding new words or structures), the stuff you can say in that language becomes simpler.
Natural LanguagesIn German, the word schadenfreude means taking pleasure from other's pain. We need a word like this in English! When something terrible happens to Paris Hilton or Tom Cruise, we revel in it. But English speakers cannot concisely describe this satisfaction!
What's a website that gets updated regularly? With posts? It's a blog. It's a made-up word that neatly describes a concept. Attaching a name to the concept makes it more real. Adding a word to English makes English harder to learn, but more powerful to use.
Programming Languages
Autoboxing and varargs in Java 5 makes it easier to express my intention without the mechanics. Compare this:List smallPrimes = Arrays.asList(new Integer[] {
new Integer(3), new Integer(5), new Integer(7), new Integer(11) });
to this:
List<Integer> smallPrimes = Arrays.asList(3, 5, 7, 11);
Language-integrated query (LINQ) in C# lets you manipulate collections declaratively rather than programatically. I describe what I want from the collection without the gory details on how to get it!
APIs
The Future interface introduces a new concept: a return value that isn't available immediately. Using Futures allows client code to parallelize work without the clutter of managing threads.
Instead of manually managing the enabled state of the attached buttons and menus, the Action interface neatly encapsulates related behaviours. This makes the button API bigger and the client code smaller.
We can certainly get around with simpler languages. But I don't think that language simplicity should be preferred over language expressiveness. Java Closures give us a huge amount of expressivity for a small amount of complexity.
Footnote: C++
When anyone makes a case against language complexity, C++ is their canonical example of what not to do. The fallacy of this argument is that much of the complexity in C++ is accidental complexity. If done carefully, adding new features to Java will not harm the language.
# posted by Jesse Wilson
on Sunday, July 01, 2007