HAKATEMIA
01Intro

What are type juggling vulnerabilities?

Easy1H 30MIN

Statically vs. Dynamically typed programming languages

The differences between statically typed and dynamically typed programming languages relate to how the programming language handles variable data types and checks their compatibility.

Static Typing

Statically typed programming language requires that the data type of variables is defined before their use. This means that the programmer must explicitly define what kind of data the variable can contain. If a variable is used in a way that is incompatible with its data type, the program will give an error. An example of a statically typed programming language is Java:

JAVA
1int variable1 = 5;
2String variable2 = "5";
3
4boolean sameSize = variable1 == variable2; // causes an error already in the code editor and never ends up as a finished program

Dynamic typing

In dynamically typed programming languages, the data types of variables are defined automatically during execution based on their content. This means that the programmer can use variables without prior declaration of their data type. This can provide more flexibility in programming, but can also cause difficulties if the data types are incompatible and the program behaves unexpectedly. An example of a dynamically typed programming language is Python.

PY
1variable1 = "5"
2variable2 = 5
3yhta_suuri = variable1 == variable2 # the code executes but the result is False

In this Python example, the code behaves correctly, but the result is false, "5" is not equal to 5. This is because although Python is dynamically typed, it is also strongly typed, which we will discuss next.

1 / 8
Hakatemia Pro

Learn to hack — start here

Hundreds of interactive courses, virtual labs and CTF challenges in your browser. Start a free trial — no card required.