< FrankJS />

The Difference Between Static and Dynamic Languages

Thinking of going dynamic? Check out The Hidden Cost of Maintaining Large Projects with Dynamic Languages.

You probably have heard of the terms dynamic and static; this post will try to help clear up any confusion you may have on the subject.

A “statically-typed” language describes a language where the check for types in the source code is done before run-time.

The tool checks to see if the code follows the rules setup by the language’s creators to see if it is type safe. If it is not, then it will result in a type error. In a statically typed language every variable is bound to both a type, at compile time by means of a data declaration, as well as to an object. Once a variable name has been bound to a type, also known as being declared, it can only be bound to objects of that type. If an attempt is made to break this convention, an exception occurs.

A “dynamically-typed” language does not feature this kind of check. Determining a type is carried out by inspection while the program is running, i.e. on the fly, during execution.

In a dynamically typed language every variable is bound only to an object. It is possible to bind a variable name to objects of different types during the execution of the program.

Also, take note that a programming language can be either compiled or interpreted, regardless of whether it is statically or dynamically typed. I mention this because often one will see the use of dynamic typing with interpreted languages and static typing with compiled languages.

Remember, it’s “when types are checked” compared to “when source code is translated”, when comparing static/dynamic and compiled/interpreted.

Frank J Santaguida, 2022