The document discusses the differences between type systems in Java and Python. It classifies type systems based on how strictly types are distinguished (strongly vs weakly typed) and when type information is acquired (statically vs dynamically typed). Java is classified as strongly and statically typed, while Python is strongly and dynamically typed. JavaScript is classified as weakly and dynamically typed.
1. Classifications of
Type Systems
What is the difference between the type
system in Java and in Python ?
Tamer Mohammed Abdul-Radi
Backend Software Engineer at Cloud9ers
tamerradi
tamer_radi
2. Classifications of type systems
We can classify any type system by answering
two questions
1. How strictly types are distinguished?
2. When type information is acquired?
3. How strictly types are distinguished?
Answer is one of two
● Weakly typed language
● Strongly typed language
4. Weakly typed languages
● A language in which types may be ignored.
● In JavaScript:
"12" - 2 == 10
(without doing any explicit conversion)
● Javascript is weakly typed
5. Strongly typed languages
● A language in which types are always
enforced.
● If you have an integer, you can't treat it like a
string without explicitly converting it.
● Java and Python are strongly typed.
6. Classifications of type systems
We can classify any type system by answering
two questions
1. How strictly types are distinguished?
2. When type information is acquired?
7. When type information is acquired?
Answer is one of two
1. Statically typed language
2. Dynamically typed language
8. Statically Typed Language
● A language in which types are fixed at
compile time.
● Values have types, and variables too! (must
match the type of values that holds)
● Java and C are statically typed languages.
9. Dynamically types langauges
● A language in which types are discovered at
execution time.
● Values have types, but variables do not!
● JavaScript and Python are dynamically
typed, because they figure out what type a
variable is when you first assign it a value.
10. Conclusion
● Java is "Strongly typed" and "Statically
typed"
○ You can't subtract "12" from 2
○ Variables have types, you have to define them in
compile time.
11. Conclusion
● JS is "Weakly typed" and "Dynamically
typed"
○ You can subtract "12" from 2
○ Variables doesn't have types
12. Conclusion
● Python is "Strongly typed" and "Dynamically
typed"
○ You can't subtract "12" from 2
○ Variables doesn't have types (or weakly typed, and
can be changed later)
○ Python uses Duck typing, which is an extreme style
of dynamic typing
○ We will talk about Duck typing later