What are the Statically typed programming languages and what are Dynamically typed languages?. In this article, I will briefly try to explain the difference between Statically vs Dynamically Typed languages.
When you started learning programming languages, you might have encountered these two terms “Statically typed and Dynamically typed Programming Languages,” and you would wonder what does it even mean if a programming language is Statically typed or Dynamically typed. Well, do not worry about that; here we will answer these questions.
Few important terms that you need to know before:
Run-Time: when the program is running (after the compilation).
Compile-Time: The period when the compiler checks for errors before even running the program.
* Statically vs Dynamically Typed *
Statically typed languages are those languages in which the type of a variable is determined prior to the execution of the program. It means that when writing code, you need to specify the type of a variable before even compiling the code. For example, let’s take C++ as an example: int a = 7; here, we will create a variable and name it ‘a,’ and we specified the variable type to an integer.
Pros and Cons of Statically typed Programming languages:
- Statically typed Programming languages usually provide better performance.
- Faster compile error feedback.
- Statically typed Programming languages have better IDE support.
- Not suitable for working with undefined data formats.
- Statically typed Programming languages take longer compilation time.
- In many cases, it requires writing more code.
The main advantage here is that the compiler checks all kinds of errors and problems, and therefore a lot of trivial bugs are caught at a very early stage.
Examples of statically typed languages are C++, C, Java, Kotlin.
Dynamically typed programming languages are those languages in which the type of a variable is determined in run-time. It means that when writing your code, you do not need to specify the type of a variable. For example, let’s take Python as an example: X = 7; here we have created a variable in Python and name it as ‘X,’ now see here you do not need to specify the type of the variable. We can reassign the value to this variable, whatever we want.
Pros and Cons of Dynamically typed Programming languages:
- Dynamically typed programming languages provide lower performance.
- Faster development.
- In Dynamically typed Programming languages, some bugs are only detectable later in run-time.
- Dynamically typed programming languages are good for undefined data formats.
If you like this article you will definitely love these articles: