Disambiguating language type systems
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";
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!
let mNum = 3; mNum = "hello"; // Valid!
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.
|Static Typing||Dynamic Typing|
|Strong Typing||C++, Java||--|
JonLuca at 14:18