What are statically and dynamically typed languages ?
Dynamically typed languages performs the type checking at runtime whereas Statically typed languages perform the type checking at compile time instead of at runtime.
Java and C++ statically type languages so we do have to declare the type of variables before using them in our program.O once you set the variable type you cannot change it as type checking is performed at compile time. Statically typed language requires to declare a variable of any particular type.
All kinds of checking can be done by the compiler, and therefore a lot of minor bugs are caught at a very early stage.
Program execution may also be made more optimized and more efficient by omitting some runtime checks.
Advantages of statically-typed languages:-
- Better code completion.
- Better performance.
- You can get help in IDE to remove compilation errors.
- It makes easier to work with relational databases and other systems which also rely on static types.
Example of C:-
So, Here we have to specify that the variable a which I am using will be of integer type. On the other side if I talk about Python then Python has dynamically typed language so variable type is determined at runtime. If we have declared a variable of one type later we can change the type of variable to a different type.
example of Python:-
a=”Python is dynamically typing language”
So, a variable in dynamically typed languages can hold different types of values throughout its lifetime and its value during execution can be anything of any shape and form and hence it is more flexible.
You don’t need a separate compilation step as scripts tend to be small so bugs have not so many places to hide.
Advantages of dynamically-typed languages:
- less verbose.
- You don’t need a separate compilation step.
That is it about the dynamically and statically typed languages. Let us know if you have any suggestion about the content published on the site.
For more such content subscribe to our YouTube channel – https://www.youtube.com/channel/UCcWR1IezEQynJnAETgK8g2w?sub_confirmation=1 and follow us on facebook – https://www.facebook.com/pristinetechschool