The definition of Dynamic Programming language says "These languages are those which perform multiple general behaviours at run-time in contrary to static programming languages which do the same at compile time. It can be by addition of new code, by extending objects and definitions".
To the best of my knowledge many programming languages have encapsulation in form of packages like Java or header files like C++. So, the code that as a programmer I will write will certainly expand at compile time and would be eventually converted to assembly code and finally to machine code. So does every high level language becomes dynamic?
Generally speaking, one can differentiate static vs dynamic programming languages by their type systems. in dynamic type system you can have the following
var x = 2
x = "c"
meaning, the type of a given variable may change during its life time. static type systems do not allow that. C# dynamic
data type is an example of this feature.
Be careful not to confuse dynamic with inferred or weak type systems. an inferred type system will not require formal declaration of the variable, but will infer the type from the assigned value. it will not allow the variable to be re-declared with different type.
var x = 2 // the type of x is int
x = "C" // compile error: incompatible types!
a weak type system is one that allows operations that are not compatible with the declared type of the variable. C allows pointers to be casted to any type:
foo(void *ptr) {
char *str;
strcpy(str, (char *)ptr);
int i = &(int *)ptr + 1;
}
all combinations of type systems exist, sometimes in the same programming langauge: static/dynamic, implicit(inferred)/explicit, weak/strong.