Dynamically VS Statically Typed Programming Languages




Following are the key differences between dynamically and statically typed languages:

STATICALLY TYPED LANGUAGE
DYNAMICALLY TYPED LANGUAGE
Variable data type explicitly defined at compile time

Example:
int myvar1 = 3;
Variable data type not defined at compiled time

Example:
$myvar2 = 3;
var myvar2= 3;
Data types are checked at the time of code compilation
Date Types are checked at the time of code execution based on the assigned value
Assigning value to variable other than the specified data-type raises an error.

For example, if we try to assign a string value to myvar1, the command will execute with an error.
Assigning value of any data-type to the variable is allowed.

For example if we try to assign a string value to myvar2, the command will execute without any error.
Some examples of statically typed programming language:

C++, C#, Java
Some examples of dynamically typed programming language:

PHP, JavaScript, Python


Refer to weakly vs strongly typed languages here.

Comments