Weakly typed languages and strongly typed languages

Source: Internet
Author: User

A strong type of language

A strongly typed language is a language that enforces type definitions, and once a variable is defined type, it is always the data type if it is not cast, and strongly typed languages include Java,. NET, Python, C + +, and so on.

For example, if you define an integer, you cannot convert the integer to a string without forcing the type conversion.

Second, weak type language

A weakly typed language is a weakly typed language defined by a variable that can be automatically converted according to the changes in the environment, without the need for a dominant cast. Weak type language includes VB, PHP, JavaScript and other languages.

As an example:

[HTML]View PlainCopy
    1. var A =5;
    2. var B = "5";
    3. Sumresult = A +b;
    4. Minresult = A- b;

The answer to input sumresult is not 10, but 55, and again the type of a is converted to a string and then spliced. The answer to input minresult is 0, which is to convert the type of B to a number and then subtract.

Three, strong type language and weak type language difference

Whether it is a strongly typed language or a weakly typed language, the fundamental criterion of discrimination is whether the language type can be changed implicitly. Strongly typed languages are slightly slower than weakly typed languages, but the rigor of strongly typed definition languages can avoid unnecessary errors.

79464196

Weakly typed languages and strongly typed languages

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.