March 12, 2018
Let’s figure out what do those terms mean
Dynamic means that value’s type is enforced, but variable’s is not, and it can represent any value at given time.
let foo = "bar"; foo = 11; foo = true;
Attention! The fact that this code is valid doesn’t mean you should do this! Do not assign values of different types to the same variable. It is super misleading and you’ll make your fellow developers super unhappy.
const strValue = "test" const intValue = 2 const result = strValue + intValue // test2
It can lead to a lot of weird behavior (I think everyone has already seen the WAT talk). We’ll get back to it later.
These definitions are more common in academic circles and both mean that everything belongs to a single type.
Here is definition from Benjamin Pierce book Types and Programming Languages
A type system is a tractable syntactic method for proving the absence of certain program behaviors by classifying phrases according to the kinds of values they compute.
Syntactic means that it is a language feature. And it basically means that a language will only generate a program when it can prove that the types align.
So in a typed language, a program might not be generated, because types might not match up because a program can contain multiple types.
Here we need to make a note about types and classes. Both are data structuring mechanisms that describe things with certain structure and behavior.
Here are two articles about types/classes, dynamic/static languages