Programming Languages Should be Simple

Programming languages should be simple, based on a small and flexible core. Why is simplicity important? A simple language is easier to learn than a complex one, and a simple language lends itself to a simple implementation, which is easy to modify.

Simple How?

What does it mean for a language to be simple? The way I judge the complexity of a language is by the number of special cases the programmer has to be aware of while using it.

A language such as C++ is definitely not simple. The sheer number of rules you have to know in order to fluently write C++ is astounding, especially where templates come into play. A loose specification, where implementation behaviour is undefined in many error cases, means there are many traps you have to know to avoid, since they can be difficult to find your way out of after you fall into them (see some examples of problems you can run into when dealing with the linker). The slow but incessant growth of features over the years coupled with an obsession for backwards compatibility leads to a monster of a language.

A language like Scheme is comparatively simple. It has a very homogeneous syntax: almost everything is a function call. There are only a few built-in syntactic constructs (things like conditionals and definitions), no keywords at all, and no operators to worry about.

Simplicity Makes Languages Easy to Learn

The most immediate advantage of having a small core language is that it’s easier to learn. If you can learn all of the language constructs and exceptions in half an hour, then you can turn your attention to what’s most important: understanding how you can use the language to write programs. It’s not that a simple programming language makes programming easy, it just prevents it from being artificially difficult. Programming is hard enough without the programming language providing its own obstacles. Programming should not be about memorization, it should be about problem solving.

Simplicity Makes Languages Easy to Modify

If the language is based around a simple core, it’s likely to be easier to implement. Besides saving the initial implementor some amount of work, a small implementation is easier to change. This allows experimentation with new features. It encourages people to make modified versions of the language, which will foster innovation and research. In the long run, that’s good for the future of Computer Science as a whole. For example, though Lisp is a minority language now, its influence is felt all over computing. Wikipedia lists over 15 different Lisp variants, and some of them, such as Common Lisp and Scheme, have more than a dozen implementations.

It’s not likely we’re going to come up with the perfect language anytime soon. By making languages simple, we can at least compromise by making it easy for others to correct the imperfections.

Posted on 2009-01-01 at 23:35. trackback