Dr. David J. Pearce

Language Complexity?


Some languages are complex, others are simple … right?  C++ versus just about anything else is a good example here.  But, it begs the question: what makes a language complex?

So, I’ve just been reading Bruce Eckel’s Artima article on Scala.  It’s actually a nice article, and I enjoyed it.  But, one thing bugged me — and, it’s nicely summarised in this quote:

But you can see from the code above that learning Scala should be a lot easier than learning Java! There’s none of the horrible Java ceremony necessary just to write “Hello, world!” – in Scala you can actually create a one-line script …

Somehow, that’s not the impression of Scala I get from the article.  It’s almost as if removing public static void makes a language easy. I don’t think ceremony has much to do with what makes a language simple or not. Sure, it reduces the amount of finger typing, but that’s something quite different.

From my perspective, a language is easy to work with if there is a clear mental model behind it.  This is something one can draw upon to understand why certain constructs exist, and when they should be used.  Take the idea of traits as covered by Bruce:

We can also mix in behavior using traits. A trait is much like an interface, except that traits can contain method definitions, which can then be combined when creating a class.

This is not helping me to understand what traits really are.  The questions are: *why would I use them?**when does it make sense to use them?*when does it not make sense to use them? Now, I’m not trying to argue that traits are (or are not) a complex feature.  The point is: this explanation does not lead me to conclude that they are “simple”.  That’s because it doesn’t give any insight into the mental model behind them.

Teaching students how to program is a good way to pick up on what concepts are difficult.  To get them to really understand something, you need to build up a mental model. For example, in explaining references/pointers, the old boxes-and-arrows diagram goes a long way.  In Java, however, there are a number of thorny issues:

(As I’m sure you know, there are plenty of other interesting examples in Java that we could talk about here)

Anyway, that’s my 2c on language complexity …