+ 6
What are the differences between static and dynamic typed languages?
What are the differences between static and dynamic typed languages?
4 Antworten
+ 13
Hello, Daniel !
Statically typed languages restrict the types of variables: a programming language can know, for example, that x is an Integer. In this case, the programmer is not allowed to do x = true; it will be an invalid code. The compiler will refuse to compile it, so we can not even run such code.
Dynamically typed languages mark values with types: the language knows that 1 is an integer, 2 is an integer, but it can not know that the variable x always contains an integer.
The language runtime verifies these labels at different times. If we try to add two values, then it can check whether they are numbers, strings, or arrays.
Good luck with programming on SoloLearn!
+ 2
Thanks alot Alex👍
+ 1
let me add some small detail, in dynamically typed languages, variables can change their type during runtime (it means in the beginning variable can be "integer" then "string" and in the end "boolean")
in c# there is "var" keyword, you can write "var i = 5;" it is equal to "int i = 5", the compiler will assign type automatically, but this variable never can change to other type
"var" can be used with "class", "var person = new Person();"
+ 1
l
x
xX