May 10th, 2003

(no subject)

This is a comment I made on this article: http://www.artima.com/weblogs/viewpost.jsp?thread=4639 this I wanted to save here for future reference... It's about the eternal (?) debate over weak vs strong tying, or as the fans of weak typing like to call it: dynamic vs static typing.

Reading all this got me thinking: is there really so much difference between dynamic and statically typed languages?

First off, what is the difference anyway? Both have some sort of type notion, since you really can't add 5 and "blabla". So the difference then lies in where the typechecking occurs. In dynamic languages, the runtime system does the checking, and there is no checking by any form of compiler. In statically typed languages, the compiler does the checking, and there is no checking at runtime.

The difference form the programmers point of view is that, with statically typed languages, there is more code to be typed, and with dynamic languages, there is are more runtime errors (whether they occur in tests or in the field).

I don't get the 'waiting for compile' point I read several times, as far as static languages go: in dynamic checking, you'll just be waiting for the tests, which (if they are good) you have written to cover all code, which will take long. I should know, since in my current environment running all tests simply isn't doable (30 min on newest pc's).

As for the evolution of languages as mentioned in http://www.paulgraham.com/hundred.html , I wonder if we won't see both sides coming together in an 'optional typing' system. You could argue that this already is the case: in C++ for example, you have a form of dynamic typing (from the programmers point of view anyway) through templates. In any lisp variant, you could implement statical typing by making the most basic element of any list a pair with 2 things, first the value you want to represent, second it's type.

Finally, I do not completely agree with the idea about as few axioms as possible. I would rather say any successful language needs as few axioms as possible while remaining usable and good libraries to do most of whatever is needed at that point in time easily. There are a few toy languages with one instruction which are supposed to be turing complete still. Can't find one right now, but Brainf*ck with it's 8 instructions is also good example over oversimplification. And C for example has good libraries for console io and memory management, which was (I guess) what was needed at the time.