Date: 09-08-2020

Type checking is the way in which a programming language enforces variable types (int, float, bool, etc). But I always forget what the difference is between strongly/weakly typed and statically/dynamically typed.

Static vs Dynamic

This defines whether the type checking is enforced at compile time or run time. If the language does type checking at compile time then it is statically typed (e.g. C++). This would prevent any type errors from occurring during run time. If it does type checking at run time then it is dynamically typed (e.g. Python).

Strong vs Weak

This defines whether the language does type conversions implicitly. If it does not do conversions implicitly then it is strongly typed (e.g. Python). If it does do conversions implicitly then it’s weakly typed (e.g. R).

For example, in Python if we have a vector with a single element that is a string type and append an int to that vector, the type of both elements is preserved.

x = ['foo']
x.append(1)
print(x)
# ['foo', 1]

But when you implement analogous code in R the type of each element is not preserved. The int variable that you append gets implicitly converted to a string variable.

x <- c("foo")
x = append(x, 1)
print(x)
# "foo" "1"