Java - Strongly Typed Language
The Java programming language is a strongly typed language ? what does it mean ?
In javascript u can create variables using "var"
ex: var a;
here variable "a" can hold char,int,float,etc so many types.
but in Java u need to declare the type of variable before using it & also u cannot directly assign variable of one type into another, u need to do casting.
strong vs. weak typing
This distinction refers to the behavior of the language when values are operated on. In a strongly typed language, operations must match the types of the values operated on (addition must be performed on numbers, for example). In weakly typed languages operations might be made on values which are inappropriate.
Example of typical weak-type language is PHP (also many other script languages):
$variable_one="hallo";
$variable_two=10;
$variable_three=$variable_two+"15";
$variable_four=$variable_one+"20";
echo $variable_three; //will result 25, the string "15" will be automatically casted to integer
echo $variable_four; //will result 20, the interpreter is confused how to handle the string "hallo"
As you can see the weak-type language has its advantages and disadvantages:
Advantages:
1. easier for beginner
2. faster to develop
Disadvantages:
1. nightmare to debug (especially if it is a large app)
2. give more tolerance for failure or wrong understanding (which could lead to serious security issues)
3. Can be a source of memory/performance hog
This big tolerance for failure which could lead to disaster is also an argument why many say JEE or .Net(C#) is much more scalable than PHP or some other weak-type script languages.
In javascript u can create variables using "var"
ex: var a;
here variable "a" can hold char,int,float,etc so many types.
but in Java u need to declare the type of variable before using it & also u cannot directly assign variable of one type into another, u need to do casting.
strong vs. weak typing
This distinction refers to the behavior of the language when values are operated on. In a strongly typed language, operations must match the types of the values operated on (addition must be performed on numbers, for example). In weakly typed languages operations might be made on values which are inappropriate.
Example of typical weak-type language is PHP (also many other script languages):
$variable_one="hallo";
$variable_two=10;
$variable_three=$variable_two+"15";
$variable_four=$variable_one+"20";
echo $variable_three; //will result 25, the string "15" will be automatically casted to integer
echo $variable_four; //will result 20, the interpreter is confused how to handle the string "hallo"
As you can see the weak-type language has its advantages and disadvantages:
Advantages:
1. easier for beginner
2. faster to develop
Disadvantages:
1. nightmare to debug (especially if it is a large app)
2. give more tolerance for failure or wrong understanding (which could lead to serious security issues)
3. Can be a source of memory/performance hog
This big tolerance for failure which could lead to disaster is also an argument why many say JEE or .Net(C#) is much more scalable than PHP or some other weak-type script languages.
0 Comments:
Post a Comment
<< Home