Typing: Static, Explicit, Implicit And Dynamic

time to read 3 min | 452 words

Another note about typing. In my opinion, people are often confused about the meaning of static typing vs. dynamic typing and explicit typing vs. implicit typing. The two are not neccearily connected. In general, a programming langague will fall into one of this categories:

  • Staticly typed, explicit typing - Java, C++, C#, VB.Net, etc
  • Staticly typed, implicit typing - Boo, C# 3.0, VB.Net 9.0 etc
  • Dynamically typed, implicit typing - Javascript, Ruby, Smalltalk, Brail :-), etc
  • Dynamically typed, explicit typing - Can't think of a single language with this, nor a single reason to want this.

Boo, C# 3.0, VB.Net 9.0 are smart enough to infer what the type of a variable is, without the developer having to tell the compiler (over and over again) what the type of the variable is.

Staticaly typed languages are very good, in my opinion, but explicit typing is a chore, nothing more. After I saw how easy it is to work with Boo, I just can't believe how hard I have to work in other languages just to make the compiler work.

Dynamic langauges are cool (Boo has some of the features that they can offer, and they are simply amazing), but you the ability to check the program for syntax validity. This is not a trivial matter. Yes, syntax violations are easy to fix, but if I write a bunch of code, and I need to fix the errors there one after the other, instead of one bunch, it's annoying and wasting my time. I'm not talking about unit testing here, I'm talking before I get to the point where my program even run.

In short, I think that the sweat spot for me is Boo. Staticly typed, implicit typing (but can be explicit if you want), with dynamic features avialable if you want them. I see the point in dynamic languages, and I enjoy doing work with Javascript (the only dynamic langauge I work with on regular basis), doing things that I could never do in C#.

But the point is that 90% of what you can do in a dynamic langauge you can do in a static one if the compiler is smart enough. The best is if the compiler allows you to say "yes, I know what I'm doing, let's do this bit on runtime".