Static vs Dynamic Typed Languages
Static Typing/Typed
- A variable need not to be defined before they are not used.
- To use a variable that is done by explicit declaration.
For example,
/* C language code */
#include<stdio.h>
void main()
{
static int sum,num; // explicit declaration
sum = 0;//use variables
num = 10;
sum = sum + num;
printf("%d",sum);
}
- Before using a variable must have to declare them.
- C, C++ and Java are statically typed languages.
- Errors are shown at compile time.
int a = "50";//error shown after execution
Dynamic Typing/Typed
- To use a variable that need not to use explicit declaration.
For example,
/* Python Code */
num1 = 5 #direct use of variable
num2 = 10
sum = num1 + num2
print(' Addition of two numbers is {0} '.format (sum))
- Before using a variable need not to be declared.
- Python,JavaScript,PHP..etc.
- Error is shown at run-time.
int sum = "Program" #checks at-line no further execution
Comments
Post a Comment