Typing in programming languages, strong,weak,dynamic,static!?
I have few confusions from the given slide-:
1) How is python strongly typed as well as dynamically typed at the same time?
2) How does strongly typed languages don't use static type checking? Shouldn't they use static type checking in fact?
3)Why doesn't compiler enforce type constraint rules in strongly typed languages? Should not it enforce?
4) What does it means by typing errors are prevented at runtime?
- EddieJLv 74 weeks ago
It can be confusing because the terms they have chosen do not necessarily fit the English definition.
In Python, you can have these 2 statements in a row.
a = 5
a = "hello"
You might think that in something labeled "strongly typed" that wouldn't make sense, because neither has the type declared, and the type changes between the 1st and 2nd statement.
But, it is considered strongly typed, because, in the 2nd statement, where the type is changed, it is changed because of an explicit action, specifically, an assignment to a different type. It is more accurate to say that <a> was NOT changed. <a> was deleted and a new <a> was created.
It is dynamically typed because <a> is not actually an integer after the first statement. It has been assigned to reference a value of an integer, specifically 5. And the new <a> has been assigned to reference a value of a string, specifically "hello". So, think of the type as being part of the value.
Keep in mind, that once you are finished with this course, you will probably never have to think about these specific terms again. But, you may come across them, and, even though you probably won't have to remember specifically what they mean, you will not be completely bewildered by the sentence, and you can always google to remind yourself.