When we talk about programming languages, we often come across the typing of a language - how it is "typed".
We can say there are two categories of defining the typing of a language:
- Static vs. Dynamic
- Strong vs. Weak
This categorization of typing represents WHEN the types are checked in the process of running your program.
When you run your program, the codes you have written are first compiled into another low-level language that the computer can directly interpret. This period of your code being compiled is referred to as "compile time".
After compilation, the computer then executes your code - or run the program. This period of your codes being run is referred to as "runtime".
meaning: types are checked during COMPILE TIME
examples: C, C++, C#, Java, TypeScript (optionally static)
meaning: types are checked during RUNTIME
This categorization of typing represents HOW STRICTLY the type restrictions are enforced.
10 + '5' // the output is '105' // number + string => string + string // JS auto-converts the number to string and concatenates the two strings
On the other hand, when you try the same operation in Python, you get a TypeError. In Python, you won't get any automatic type conversions. You have to explicitly convert the data type. Python is a strongly typed language.
meaning: the rules/restrictions relating to data types are STRICTLY enforced
examples: Python, Ruby, Java, C, C++, C#, TypeScript
meaning: the rules/restrictions relating to data types are LOOSELY enforced