Computer Language Complexity

2006-10-26, , , Comments

A debate has been raging on the ACCU general email reflector. It started with some ugly C++ code and ended up attempting to answer some more general questions about computer languages:

  1. Can a language be both small and powerful?
  2. What makes a language powerful anyway?
  3. Is it better for (any necessary) complexity to be in the language or in its associated libraries?
  4. Shouldn’t we just admit that programming is hard?

C++ came in for criticism from some, though, as its designer and original implementer has been compelled to remind us:

The major cause of complaints is C++’s undoubted success. As someone remarked: There are only two kinds of programming languages: those people always bitch about and those nobody uses.

Who is that someone? I’d like to disagree with him — or her. For now, though, I want to record some of the answers to these questions which I did agree with.

Can a language be both small and powerful?

Yes. Russel explains:

… If the language comprises a small, orthogonal set of higher order functions and primitive operations, all other things can be built from them. Small, powerful language, large, structured library of usable software.

Clearly, though, there’s some tension between “small” and “powerful”. For example, when generators were added to Python, the language gained in power at the expense of size: in this case, though, the gains more than outweighed the costs.

It’s also noteworthy that the next major revision of Python actually aims to make the core language smaller. Yes, Python isn’t as widely-used as C++ (yet), but it is a major language and it does take backwards compatibility very seriously. I guess it’s the kind of progression which can only happen when you have a benevolent dictator for life rather than a standards committee. Of course, it remains to be seen how well the transition to Python 3.0 actually goes.

What makes a language powerful anyway?

Paul came up with a practical and appealing definition.

The language facilitates more with less required of the programmer.

On examination, though, this doesn’t distinguish between the power of the language itself and the power attained through associated libraries. It’s possible for the language itself to be simple and powerful, but for the range of available libraries to be poor, meaning that the programmer has to (for example) write their own database access code. It looks as though Scheme currently falls into this category. And it’s possible for a language to be less powerful but the range of libraries to be excellent, meaning that the programmer (for example) can’t overload operators, but can (for example) access a database. I’d say Java falls into this category.

Should complexity be in the language or its libraries?

It’s better to keep the core of the language as small and powerful as possible. It’s far easier to extend what you can do with a language by adding libraries (and it’s easier to deprecate libraries than deprecate language features).

Shouldn’t we just admit that programming is hard?

We should. It is. But we should still strive for simplicity.