Friday, April 18, 2008

Pluggable Type Systems and the future of Programming Languages

Programming languages come and go at an astonishing pace, and few enjoy the spotlight of geek popularity for long. Heck, Java used to be cool. And so did Perl. The pace at which technology moves sometimes makes me wonder if we are actually getting anywhere, or if we are just moving to be moving. There's a sort of elite snobbery among hackers that shuns popularity. Did Java fall out of favor simply because it became too popular?

Although I certainly wouldn't put it past some corners of hackerdom to shun something just because it is popular, I do not think this is what is happening in the mad race for newer and shinier programming languages. After all, Isn't Java better than c++? And aren't Python and Ruby better than Perl? And isn't Javascript... well, never mind about that.

The point is that languages don't fall out of favor among hackers simply because they become popular. They fall out of favor because hackers are very promiscuous about their programming languages and move on to something better when they find it. And since there is a whole lot of creativity in that community, something better comes along pretty regularly.

I don't expect innovation to continue at this pace forever, though. Many of the good ideas making their way into the mainstream today were invented in academia 30 or 60 years ago. Eventually the popular languages are going to converge around a more-or-less standard set of features, and there will be less need for such rapid innovation.

Encouragingly, I think we're catching a glimpse of one area around which programming languages are going to converge in the near future: pluggable type systems (that is, optional type systems which are dynamic in nature and can be removed, modified, or extended). This is happening from both directions: dynamic languages are adding optional static features, and static languages are becoming more dynamic. Consider the signs:
  1. Javascript 2 will have optional typing
  2. Python 3 will have function annotations, which have no semantic meaning on their own but can be interpreted by 3rd-party libraries.
  3. One of the JRuby developers is working on a toy Ruby dialect that adds type annotation to the language. Interestingly, the type annotations are valid Ruby and would just be ignored (or immediately garbage-collected) by a normal Ruby interpreter - giving them a pluggable flavor.
  4. The next version of c# will support dynamic method lookup.
  5. Qi, an interesting lisp-like language, has an optional type system.
  6. Boo, a statically-typed scripting language for the CLR, has a "duck" type which allows method lookups to be done at runtime.
Granted, some of these examples are obscure. But the number which are not is pretty remarkable. It shows that with regard to type systems, we as community of programmers are learning to be pragmatic rather than purist. I think this is a real sign of maturity because it means we are transcending the static/dynamic holy wars. The Java design philosophy of ruthless consistency is no more. We've been down that road, and we don't like what we saw. We know that not everything is an object and that gee, it would be nice to be able to remove checked exceptions if we wanted to. And although I don't know where we will end up, I do know that it will be better than where we are today.

No comments: