mahiwaga

I'm not really all that mysterious

teaching a computer to read your mind

The crux of the eternal static versus dynamic typing debate is just how much are you willing to let the computer (or more accurately, the language implementers) decide what you mean. Those who favor static typing tend to favor explicit direction over implicit intuitive understanding, and strictly-defined categories and hierarchies rather than free-for-all tag webs and interconnections. The static typist immediately recognizes that the computer (specifically, the compiler or the interpreter) is a non-intelligent entity that must be told exactly what to do, or else you’re liable to saw your own foot off. The dynamic typist, while not delusional about just how intelligent the computer is, is willing to have a little more faith in the language implementers, believing that they will do the Right Thing™ with the input that is fed to them.

It is apt that most dynamically typed languages are interpreted. It is not just metaphoric that the most important part of the interpreter is the parser. What I believe the goal of dynamically-typed languages is to be able to take input from a programmer, and output machine language that does pretty much what the programmer means. In other words, interpreters of dynamically-typed languages need to be able to understand human idioms.

This is intrinsically more likely to result in unexpected behavior, but we aren’t talking about obvious operations like addition or concatenation. We’re talking about more abstract things, like how certain tables in a database should be related to one another, or what to do with that extra parameter when the object passing a message isn’t expecting it.

The static-typist is most comfortable with telling the computer exactly what to do in these circumstances. This can be a time-consuming, and error-prone activity. The dynamic-typist is probably more willing to let the language implementers make these decisions, with the knowledge that what you thought you put in may not be what the interpreter actually thinks you put in, resulting in perhaps wildly erroneous output (but not a crash!)


Some authors comment on the fallacy that we’re talking about the difference between strong typing and weak typing. For example, any language that lets you implicitly cast between different types is de facto a weakly-typed language, and the most popular statically-typed languages allow you to do just that.

So the real axis is static vs. dynamic typing.

But I think another level on which to think about these things is the difference between brittle handling and flexible handling.


In the day and age when we have clock cycles to spare, with CPU cores running idle, I think we should really expect more of our computers. I really think that computer programming should be more tolerant of bad input. I’m not saying that a compiler should just ignore syntax errors, or let a grossly mis-cast variable go ahead and ruin your stack, but language implementers really should start using all this extra CPU time we have. Capabilities like self-reflection are the beginnings of this.

initially published online on:
page regenerated on: