3 ms·
There’s two main attributes of languages as far as typing goes: Static vs dynamic: when a variable is declare does the compiler know and enforce the type? e.g.
by shepherdjerred 5y ago
There’s two main attributes of languages as far as typing goes:
Static vs dynamic: when a variable is declare does the compiler know and enforce the type? e.g. can I declare a variable as a string and then assign it an int to it? If you can then you have a dynamic language. If you can’t then you have a static language. Examples of static are Java, Rust, and C++. Examples of dynamic are Python, JavaScript, and Ruby.
The other attribute is weak vs strong typing. Weakly typed languages will coerce types where appropriate. for example if I try to compare “1” with 1 a runtime error occur for a strongly typed language, a weakly typed language will coerce “1” -> 1 and return “true”. Examples of strongly typed languages are Ruby and Java. Examples of weakly typed languages are JavaScript.
Mostly statically typed languages are strongly typed.
My definitions probably aren’t rigorous, but I think they’re good enough.