Static vs. Dynamic Type – Maybe More Important Than You Think

Most programmers think they know what this means. I’ve heard it many times because I often ask developers on job interviews to tell me what they prefer.

Why?

Might sound like a trivial question, but  it is quite relevant. Programming languages are just tools and we want to know whether our possible future colleague is able to understand how things work.

And The Answer Is…

Most of the time, the candidate strongly prefers one system (based on the programming language used mostly). Basically, I have yet to see a C programmer telling me that she/he prefers dynamic type.

But the first question was easy, the second question is always “Why?“.  I got to write this article thanks to the answers I received.

I’ve discovered that nine out of ten developers are confused (to say the least) about type systems.

Let’s review the common mistakes:

I prefer the dynamic type because I do not have to declare everything – many developers think that static type means to declare types and dynamic not. That is not correct.
I do not like dynamic because nasty things can happen by not declaring types – this comes from the other side of the barricade, usually from C/C++ developers who don’t like PHP. But once you ask them about Ruby, chances are they will like it, although Ruby is dynamic typed as well.
Dynamic typed programs are less reliable – there is no reason for this to happen, provided you are using the same development process.
Static typed enforces a process – just because you have to think about the interfaces first. 🙂 Yeah, many programmers start with writing the C header files…
The compiler can catch many errors that otherwise would ship to customers – no need to explain this, I think.

Learn About Type Systems

There are at least twenty funny things I’ve heard in the past 2-3 years on this subject. Some are so “exotic” that it is hard to remember them. If you are confused, please read this. It has a couple of minor errors, but they are debatable. It’s the best blog article about type systems I know. There are also books, but let’s stay to the basics :).

And remember that programming is fun no matter the type of the programming language you use. Static and dynamic types are like sword and knife. Both can cut, but it is unlikely you’d ever want to use them for the same thing.

[youtube]http://www.youtube.com/watch?v=pdCty8dM1VE[/youtube]

Just a very dynamic type guy. And strong as well! 🙂

Post A Reply