Is Java, python an explanatory or a compiled language?

Source: Internet
Author: User
Tags python script

Python explanatory type (function write before call)

Java compilation (multiple requests) + explanatory type (less requests)

Explanatory language definitions:

The program does not need to compile, when running the program is translated, each statement is executed when the translation. In this way, the explanatory language needs to be translated one at a time and is less efficient each time it is executed.

Modern interpretive languages usually compile the source program into intermediate code, and then use the interpreter to translate the intermediate code into the target machine code, which is executed.

Compiler language Definitions:

Compiler language written program before being executed, need a special compilation process, the program compiled into machine language files, such as EXE files, later to run without re-translation, directly using the results of the compilation (EXE file), because the translation is done only once, the runtime does not need to translate, Therefore, the program execution efficiency of the compiled language is high.

Python working process:

Python is an interpreted programming language. You can also compile the Python script into a pyc file, or it will be a python virtual instruction that runs in Python after compilation.

Python first compiles the code into bytecode, and executes it in the byte code interpretation. The byte code corresponds to the Pycodeobject object in the Python virtual machine program, and the PYc file is the representation of the bytecode on disk.

The time to create the PYC is when the module is loaded, that is, import.

Python test.py compiles the test.py into bytecode and interprets execution, but does not generate TEST.PYC.

Java working process:

Java's first process is Javac compilation, of course the target file is bytecode (bytecode). There are three possible ways of handling this:

1. Runtime, generate bytecode (bytecode) files, and then by the JVM-by-article interpretation of execution;

2. At runtime, some code may be translated by the JIT (Just-in-time Compiler, instant compiler) to the target machine instruction (in method as the translation unit, will be saved, the second execution without translation) directly executed;

3. RTSJ. After Javac, perform the AOT two compilation to generate the static target platform code (typically IBM Webshpere REAL time).

In fact, it is now a bit of a struggle to classify programming languages with compiled and interpreted types. In general, the Java compilation results are "interpreted by the JVM", so it can be said, and in fact, this "is a compilation or interpretation" of the concept here has been a little blurred, the process of understanding it is OK, do not need to next "precise" definition.

And I'm still in favor of the notion that Java is a compiled language, because "compiling" is essentially "converting a relatively high-level language into another relatively low-level language."

Byte code and machine code:

The difference between a byte code and a machine code (or native code):

C code is compiled into machine code and will be executed directly on the processor. Each instruction controls the CPU work.

Java code is compiled into bytecode and will be executed on the abstract computer of the Java Virtual Machine (JVM). Each instruction is handled by the JVM and the JVM interacts with the computer itself.

In short: machine code is much faster, but bytecode is easier to migrate and more secure.

Java-jit:

We all know that the local machine code speed is much faster than the byte code. So what happens if we can compile some bytecode directly and then run it out of the machine code? We have to pay some price (such as time) to compile the bytecode to the local machine code, if the final run time is faster, then the cost is worth it. This is the motivation of the JIT compiler, a technique that mixes the benefits of interpreters and compilers. Simply put, JIT is trying to improve the speed of the Scripting interpreter system by compiling technology.

For example, a common method used by the JIT (Just-in-time Compiler, instant compiler) is to identify the frequently executed bytecode and compile the machine code for the cost to cache the result. When the same bytecode is executed again, the precompiled machine code is taken and the benefits (such as speed improvement) are obtained.

pypy:

Put the JIT into the Python language (see Appendix to the previous results). Of course there are other purposes: PyPy goal is to become a cross-platform, light memory, support Stackless (Stackless provides a micro-threading extension for Python, with concurrency features). But compiling in time is its real selling point. Based on the average of a series of time tests, it is said that performance can be increased by 6.27 times times.

Is Java, python an explanatory or a compiled language?

Related Article

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.