Statically typed languages vs Dynamically typed languages

Joseph Husney
2 min readMar 12, 2021

When discussing key differences between various programming languages, one topic that generally comes up is Dynamic vs Statically typed languages.

What is a statically typed language? In short, it is a programming language which forces the coder to identify the type of the variable he is declaring. For example, in a statically typed language (such as java), the programmer will be forced to write:

int number = 10; // The int operator tells java that the variable     // 'number' references to a memory location which stores an integer // value which happens to be 10

You can also write as follows:

bool trueOrFalse;

That code tells java that the variable ‘trueOrFalse’ references to a place in memory which is of type boolean. As we see, you don’t need to declare the value when you declare the variable. However, you must declare the type.

Now let’s jump over to define dynamic typing. Languages such as python and others do not force the programmer to declare the type of the variable. Therefore, this is completely acceptable in python:

number = 6 // The compiler recognizes 6 to be an integer without 
//forcing you to declare it an integer

Pro’s and Con’s: (this is not an exhaustive list as there are many other considerations)

Statically typed language:

a) More secure — meaning a user cannot break the code that easily as we will see with an example.

b) Ide Assistance — because the ide knows that it is an int, it can give the user suggestions based on the type.

Dynamically typed language:

a) More programmer friendly — no need to worry about types ( until it breaks :) )

b) Less wasted time on debugging code

To conclude, I will say that it depends on the kind of project and the programmers preferences. There is no write or wrong as it depends on the situation.

--

--