HOME/Articles/

Disambiguating language type systems

Article Outline

A common mistake people make is conflating strong typing with static typing.

There are four key terms when discussing a languages type system:

  • Strong typing
  • Weak typing
  • Static typing
  • Dynamic typing

A strongly typed language is one in which the type of a variable is explicitly declared, like in C++:

int mNum = 3;
char mWord = "hello";

A weakly typed language is one in which the type is not explicitly declared, like in Python or JavaScript.

let mNum = 3;
let mWord = "hello";

A statically typed language is one in which the type of an object cannot change, such as in Java. Once an object is declared with that type, they are bound for the lifetime of that object. This information is used by a static type checker to guarantee certain properties about the code. It verifies that an object declared in one type can't be redeclared in another.

int mNum = 3;
String mString = "Hello";
mString = 2; // Error!

A dynamically typed language is one in which the type of the object can change, like in JavaScript:

let mNum = 3;
mNum = "hello"; // Valid!

Notes

As far as I know, all strongly typed languages are static - strong is a superset of static. There are also very few languages that are weakly statically typed. Below are some examples of languages and where they fit in the type system described above.

<div class="table100 tableTop ver1 m-b-110">

Static Typing Dynamic Typing
Strong Typing C++, Java --
Weak Typing Boo JavaScript
</div>