visit
First of all, what are all these words - Statically - Dynamically - Strongly - Weakly Typed Languages?
This is how you can classify programming languages:
In statically typed languages type checking happens at compile time. Whereas, in dynamically typed languages, type checking happens at run-time.
Type declaration
Static: All variable types have to be explicitly stated as this information is required at compile time.
For example in Java
float f = 0.5;
Dynamic: Explicit declaration is not required as type is assigned to a variable at runtime.
For example in Python
f = 0.5
Performance
Static: Do more processing at compile time but give better run-time performance.
Dynamic: More efficient compiler/interpreters, but type-checking at run-time affects performance.
Flexibility and Errors
Static: Is less prone to runtime errors but provide less flexibility to programmer.
Dynamic: Provides more flexibility but more prone to runtime errors.
Remember It
A quick hack to remember what are statically typed and dynamically typed language, is to call them by their full names
==> Statically type-checked languages.
==> Dynamically type-checked languages.
The language cloud. Courtesy: .
It’s a spectrum* (disclaimer at the bottom). So, we will just go ahead and learn the terms the way they are often used.
In Strongly typed languages once a type is assigned to a variable say at run time or compile time, it retains that type and can’t be intermingled in expressions with other types easily.
For example in Python
data = “string1” //Type assigned as str at runtime
data = 5 //Type assigned as int at runtime
data = data + “string2” //Type-error str and int can’t be concatenated
Whereas, in Weakly typed languages, once a type is assigned to a variable say at run-time or compile-time, it can be intermingled in expressions with other types easily.
For example in Javascript
$data = “string1” //Type assigned as str at runtime
$data = 5 //Type assigned as int at runtime
$data = $data+“string2” //str and int get concatenated
Type checking ensures that correct variable types are part of an expression. In Statically type-checked languages, type checking happens at compile time, whereas in dynamically type-checked languages, type checking happens at run-time.
If you go into the nitty gritty and try to find THE right answer, you will come back (exactly!).
Turns out, there is of these terms agreed throughout the industry. It’s a spectrum. But the terms still get thrown around a lot. So, I went digging. calls Java a strongly typed language. But uses no such term.Find me on Twitter, Facebook, Linkedin, Quora, Github, Medium, Gmail @jarpit96