Weakly typed language, strongly typed language?

First, what is a weakly typed language, strongly typed language?

Strongly typed and weakly typed mainly standing angle variable type classifying process.

It refers to a strongly typed variables allowed implicit type conversion, weak type allows implicit type conversion.

Therefore, the key is of variable data type conversion.

 

Second, what is implicit type conversion?

Implicit means that there is no obvious source code for the type of conversion, that is to say, a variable, you can assign him to direct a string, you can assign value to him directly, you can also directly type string variables and numeric types the variables together, although the end result may not be obtained as you think, but it certainly will not complain.

This is implicit type conversion, a weakly typed language, such as javascript, php.

For example (var result = 5 + 5; // two numbers
    alert(result);  //outputs "10"
    var result=5+'5'; // a number and a string
    alert(result);  //outputs "55")

Java is a strongly typed language, does not allow implicit type conversion, that is to say, if you need to take a string as an integer variable to use, you must explicitly convert the variable type is good.

For example (int d = 10 double c = 12.3

    int a = a + (int) c // this is the value of a 22)

in other words:

  • Strongly typed language, when you define a variable is a type, if the code without explicit conversion (mandatory conversion) before, it will always be this type, if it as another type to use, it will error
  • Weakly typed language, you want this variable as what type to use, just as what type to use, language parser automatically (implicitly) converted.

Third, compare

Apparently so weak type developers of some more effort, some data types are not very complex scenarios can not focus on the basic data types of problems, which can improve business processes focused force developers to improve development efficiency logic.

But again, weakly typed because of its characteristics, the developers in the development process to detect the intensity of types is not big enough, thereby increasing the likelihood of the types of data problems.

In addition, the operating efficiency of a weakly typed language, memory utilization obviously not as strongly typed language. Since during operation in a weakly typed language, there is implicit conversion of variable types, some more operations to be performed, and, when allocating memory, will be allocated with more general consideration, and specifically for the various types of strong typing of variables tailored to allocate memory, memory utilization will obviously be higher than the weakly typed.

Guess you like

Origin www.cnblogs.com/Dmand/p/12076197.html