What are the differences between static and dynamic typed languages? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 6

What are the differences between static and dynamic typed languages?

What are the differences between static and dynamic typed languages?

17th Jul 2018, 6:12 PM
Ibejih
Ibejih - avatar
4 Answers
+ 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!
17th Jul 2018, 6:30 PM
Alexander Sokolov
Alexander Sokolov - avatar
+ 2
Thanks alot Alex👍
17th Jul 2018, 7:19 PM
Ibejih
Ibejih - avatar
+ 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();"
20th Jul 2018, 1:32 PM
Gevorg Baghdasaryan
Gevorg Baghdasaryan - avatar
+ 1
l x xX
1st Sep 2018, 5:52 AM
José Gpe. Bermea Limón
José Gpe. Bermea Limón - avatar