Compiling and Interpreting (Java)

Source: Internet
Author: User

computers can not directly understand the high-level language, only directly understand the machine language, so the high-level language must be translated into machine language, the computer to perform high-level language programming programs. There are two ways of translating, one is compiling, the other is explaining. The two ways are only a different time to translatecomputers can not directly understand the high-level language, only directly understand the machine language, so the high-level language must be translated into machine language, the computer to perform high-level language programming programs. There are two ways of translating, one is compiling, the other is explaining. The two ways are only different in the time of translation. The compilation (compilation, compile) definition is divided into static and dynamic two types:

1, the process of generating the target program from the source program written by the compiler program from the source language.

2, using the compiler program to generate the action of the target program.

In popular terms, compiling is the high-level language into the computer can recognize the binary language, computers only know 1 and 0, the compiler to the people familiar with the language into binary.

compiled language written program before execution, need a special compilation process, the program compiled into machine language files, such as EXE files, later to run the words do not have to re-translate, directly using the results of the compilation (EXE file). Explanation:interpretation is different, the interpretation of the language of the program does not need to compile, save the process, the interpretation of the language in the process of running the translation, such as the explanatory Basic language, a special interpreter can directly execute the BASIC program, each statement is executed when the translation. Such explanatory language should be translated once every time it is executed, and the efficiency is lower. Explanation is a sentence of translation.

Because the translation is done only once, the runtime does not need to translate, so the program execution of the compiled language is highly efficient, but it cannot be generalize, the interpreter of some interpreted languages can even make the performance of the interpreted language more than the compiled language by dynamically optimizing the code at runtime.

Compiled and interpreted type, both have pros and cons. The former because of the fast program execution, the same conditions on the system requirements are low, so like the development of operating systems, large applications, database systems are used, such as C/S, Pascal/object Pascal (Delphi) are compiled languages, and some web scripts, Server Scripts and auxiliary development interfaces The programs that are not fast-to-speed and require compatibility with different system platforms often use explanatory languages such as JavaScript, VBScript, Perl, Python, Ruby, MATLAB, and so on.

However, with the upgrading of hardware and the transformation of design ideas, compiling and interpreting languages are more and more general, mainly embodied in some emerging high-level languages, and the interpretation of the language's own characteristics also makes the compiler manufacturers willing to spend more cost to optimize the interpreter, interpreted language performance beyond the compiler language is also inevitable.

Java Run steps:

. java file, compile the->.class file, compile the. Class bytecode,. class requires the JVM to interpret, and then explain the execution. Java is very special, Java programs need to compile but not directly compiled into machine language, that is, binary language, but compiled into bytecode (. Class) and then interpreted in the manner of execution. After the Java program compiles the class belongs to the intermediate code, is not the executable program EXE, is not the binary file, therefore needs an intermediary to interpret the intermediate code in the execution time, this is the Java interpreter, also known as the Java Virtual Machine (JVM), is called the JDK.

Because the Java interpreter uses a system-independent byte-code instruction technique. That is, on any different operating system, as long as the proper installation of the Java operating systems, there is a platform to write debugging Java programs, in distributed applications, the Java feature enables the same Java program to run on different systems, thereby improving the software production efficiency. Portability is an extension of cross-platform features that are cross-platform and secure for portability. Java programs, Java class Libraries, Java compilers, and Java systems all have portability.


Having said so much, let's look back at whether Java is a compiled or interpreted type. First, Java needs to be compiled, the interpreted language does not need to compile, but the result of Java compilation is not the same as the other compiled language binary files, but the class file. From this point of view, Java is in the middle of the two; After Java compilation is complete, the operating system cannot run directly, but requires the Java virtual machine to interpret the execution class bytecode file. Therefore, the virtual machine separates the bytecode program from the operating system and hardware, so that Java programs can execute on heterogeneous platforms, and from this point of view, Java is also an interpreted language. If, strictly speaking, Java does belong to a semi-compiled semi-interpreted language, Java is an interpreted language only from the final execution step. As to what kind of language it belongs to, or the benevolent see of the beholder.


Compiling and Interpreting (Java)

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.