Where are dynamically typed languages heading?

As with most other kids in the 1980s I grew up programming in BASIC. Variables weren’t strongly typed they just held values. Type mismatches were reported at runtime with the ‘Type mismatch at line xx’ error. If you wanted to start running a different piece of code you could simply GOTO whatever line you wanted. BASIC was a great language to learn programming in, you were in charge and the computer did the best to keep up.

Pascal on the other hand was something quite different. Pascal didn’t just run (at least the version we used didn’t), it needed to be compiled first. Variables needed to be declared ahead of time with their type specified before you even used them! No longer could you just jump around the code, instead you had to split the program up into functions and carefully control how they interacted. I hated Pascal. I preferred 6502 assembly (with an instruction set so limited there was no multiply operator) to Pascal.

When I reached University I started to realize that most languages were strongly typed and pre-compiled. I soon learned to love C and later C++ and gradually accepted the wisdom of the day that ‘The compiler is your friend’. Recently, however, there’s been this glut of dynamically typed languages. People who I respect have talked about the benefits but I really don’t agree. It feels like the Emperors New Clothes, only the very intelligent people can understand the true benefits. If you try and pull up any problems with dynamic typing, such as the obvious run-time error possibilities, they simply blank you out with a Test Cases argument.

What they don’t appear to realize is that all the statically typed language guys have had intrinsic test cases all along. The test cases have been built into the very fabric of the language, the typing system. If you declare something as a date and try to put a number in it the compiler will let you know. With most statically typed languages a successful compilation has already weeded out thousands of potential run-time cases. When do you ever need a variable to hold different types of values in a controllable and maintainable way? Generic algorithms, containers? Sure, but languages like C++ and C# give you Generics yet maintain all the benefits of static compilation.

Here’s what I predict, very successful and popular dynamically typed languages will eventually develop automated test cases. These test cases will check that types of values passed around the system are consistent and can be handled. There might even be language enhancements to help the automated test cases understand what types a given piece of code can handle. The only thing I wonder is whether or not they will call it a statically typed compiler?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s