A preliminary understanding of static language and dynamic language

Source: Internet
Author: User

has been working on Java development, and scripting languages such as JavaScript are used when developing Java Web applications. JavaScript is a dynamic language, mainly based on browser parsing and running, at the beginning of the language is not called javasript, and then why JavaScript? Mainly because of the commercial operation of the consideration. At that time Javaweb developed wind water, in order to improve their popularity, so renamed to JavaScript. If you are using Java development projects, it is not appropriate to use JavaScript to develop programs. First Java is compiled by the compiler and then runs on the JVM based on the platform, so when developing with tools, the compiler can tag where syntax errors occur at any time. While JavaScript is the interpreter for compiling, and the interpreter is embedded in the browser, so when the problem of syntax error, only when the browser run to realize that there is a problem, it is not easy to use.

There is also a significant difference between Java and JavaScript, where Java's reference to each base type must indicate which type of reference to use at development time. JavaScript Initializes a reference to the base type with Var, but when the program runs it can always tell whether it is a string or a numeric type. and perform the corresponding operation. When you first touch JavaScript language, you think JavaScript is a weak language type. Later on the language further understanding, found in fact Javascrip is also a strong type of language. is a strongly typed language, mainly because the grammatical aspect of the type is mandatory, such as the definition of a variable is a string, so when the program is run to determine the string, you can invoke the corresponding string manipulation function. When you define a variable that is a numeric type, a syntax error is prompted when you call a function on a string. Java defines what type of variable it is, and JavaScript determines what type it is at run time based on the corresponding value, which seems a bit smarter than the Java language at this point. But this also poses a risk of type confusion, although this risk can be avoided. The syntax for this design is also determined by the scripting language limitations.

As stated above, JavaScript is run based on the interpreter in the browser and the runtime knows the definition and logic you write, so it doesn't seem to make sense to define variables in various types at the time of writing, even when designing a language with variable types like static languages. It is more convenient to simply explain to the interpreter what type of value it is, but also to verify that the type and direct values you indicate are consistent during the interpreter's translation. Therefore, dynamic language is very different from static language.

A preliminary understanding of static language and dynamic language

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.