Home Common Problem What is the difference between compilation and interpretation

What is the difference between compilation and interpretation

Jun 29, 2021 pm 12:49 PM
compile explain

Difference: 1. Compilation is to translate the source program into executable target code; the interpreter does not generate target code. 2. The interpreter can be used across platforms; the compiler is not cross-platform. 3. The interpreter can be modified at any time and it will take effect immediately; the compiler cannot. 4. The interpretation program has low running efficiency; the compiler execution speed is fast.

What is the difference between compilation and interpretation

The operating environment of this tutorial: Windows 10 system, Dell G3 computer.

Compilation is to translate the source program into executable target code, and translation and execution are separate; while interpretation is to complete the translation and execution of the source program at one time and does not generate storable target code. This is just an appearance. The biggest difference between the two is: for interpretation and execution, the control when the program is running lies with the interpreter and not the user program; for compilation and execution, the control at runtime lies with the user program.

The interpretation has good dynamic characteristics and portability. For example, when the interpretation is executed, the type of variables can be dynamically changed, the program can be modified, and good debugging diagnostic information can be inserted into the program. The interpreter is transplanted to a different system, the program can run on the system with the transplanted interpreter without modification. At the same time, the interpreter also has great shortcomings, such as low execution efficiency and large space occupation, because not only space must be allocated to the user program, but the interpreter itself also occupies valuable system resources.

The compiler compiles each statement of the source program into machine language and saves it into a binary file. In this way, the computer can directly run the program in machine language at runtime, which is very fast;

The interpreter only interprets the program one by one into machine language for the computer to execute, so the running speed is not as fast as the compiled program.

The difference between compilation and interpretation:

1. Different communication methods with computers

The interpreter does not generate object code, it takes out the statements in the source program one by one , interpret and execute at the same time; the interpreter interprets the source code file into machine language and hands it to the CPU for execution.

Compilation is to translate the source program into executable target code and execute the executable program file. Translation and execution are separated.

2. Different operating environments

The interpreter can be used across platforms, because the interpreter has already done a good job of interacting with different platforms, and the source code written by the user does not need to consider the differences. The source code can be executed directly on all platforms.

The cross-platform nature of the compiled program is not good. Different operating systems call the underlying machine instructions differently, and different machine code files need to be generated for different platforms.

3. Development convenience

The interpreter can be modified at any time and it will take effect immediately. After changing the source code, run it directly to see the effect

The compiler will modify the source code every time. All must be recompiled to generate machine code files

4. Running speed

Interpreted programs have low operating efficiency. All codes need to be interpreted and executed by the interpreter, and the speed is much slower than the compiled type.

Compiled programs execute quickly because your program code has been translated into machine language that the computer can understand.

For more related knowledge, please visit the FAQ column!

The above is the detailed content of What is the difference between compilation and interpretation. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

C++ compilation error: undeclared identifier, how to solve it? C++ compilation error: undeclared identifier, how to solve it? Aug 22, 2023 pm 03:34 PM

When programming in C++, we often encounter the problem of undeclared identifiers. This usually occurs when undefined variables, functions, or classes are used, causing the compiler to fail to recognize these identifiers, resulting in compilation errors. This article describes common causes of undeclared identifier problems and how to resolve them. Common Causes Undeclared identifier problems usually arise from the following reasons: Variables, functions, or classes are not declared correctly: You should declare variables, functions, or classes before using them. If the variable is not declared or function

What is the analysis of 2.8k screen? What is the analysis of 2.8k screen? Jan 02, 2024 pm 12:21 PM

We often see the introduction of how many K screens we have when buying TVs, computers or mobile phones, such as 2.8K screens. At this time, there will be friends who don’t know much about electronic devices and will be curious about what this 2.8K screen means and what the resolution is. What does 2.8k screen mean? Answer: 2.8k screen means that the screen resolution is 2880*18002K, which means the number of horizontal pixels is greater than 2000. For the same size screen, the higher the resolution, the better the picture quality. Introduction to resolution 1. Since the points, lines and surfaces on the screen are all composed of pixels, the more pixels the monitor can display, the finer the picture, and the more information can be displayed in the same screen area. 2. The higher the resolution, the greater the number of pixels, and the sharper the sensed image.

Why does Linux need to compile source code? Why does Linux need to compile source code? Mar 17, 2023 am 10:21 AM

Reasons: 1. There are many versions of Linux, but each version uses different software or kernel versions, and the environment that the binary package depends on may not be able to run normally, so most software directly provides source code for compilation and installation. 2. Easy to customize to meet different needs. 3. Convenient for operation and maintenance and developer maintenance; source code can be packaged as binary, but packaging this software will require costly extra work, including maintenance, so if it is source code, the software manufacturer will maintain it directly.

Why does my Go program take longer to compile? Why does my Go program take longer to compile? Jun 09, 2023 pm 06:00 PM

In recent years, Go language has become the choice of more and more developers. However, compared to other programming languages, the compilation speed of Go language is not fast enough. Many developers will encounter this problem when compiling Go programs: Why does my Go program take longer to compile? This article will explore this issue from several aspects. The compiler architecture of Go language The compiler architecture of Go language adopts a three-stage design, which are front-end, middle layer and back-end. The front-end is responsible for translating the source code into intermediate code in Go language, and the middle layer will

Compilation and decompilation techniques in Java Compilation and decompilation techniques in Java Jun 09, 2023 am 09:43 AM

Java is a very popular programming language that is widely used to develop various types of software. In Java development, compilation and decompilation technology are very important links. Compilation technology is used to convert Java code into executable files, while decompilation technology allows one to convert executable files back into Java code. This article will introduce compilation and decompilation techniques in Java. 1. Compilation technology Compilation is the process of converting high-level language (such as Java) code into machine language. in Java

C++ compilation error: The function parameter list is too long, how to solve it? C++ compilation error: The function parameter list is too long, how to solve it? Aug 21, 2023 pm 11:19 PM

C++ compilation error: The function parameter list is too long, how to solve it? When writing programs in C++, you sometimes encounter such a compilation error: the function parameter list is too long. For C++ beginners, this may be a headache. Next, we’ll cover the causes and solutions to this problem. First, let's take a look at the basic rules of C++ function parameters. In C++, function parameters must be declared between the function name and the opening parenthesis. When you pass a function parameter, you tell the function what to do. These parameters can be any

Can go language be compiled? Can go language be compiled? Dec 09, 2022 pm 06:20 PM

The go language can be compiled. Go language is a compiled static language, a programming language that requires compilation to run. There are two commands for compiling Go language programs: 1. "go build" command, which can compile Go language program code into a binary executable file, but the binary file needs to be run manually; 2. "go run" command, The Go language program will be run directly after compilation. A temporary file will be generated during the compilation process, but an executable file will not be generated.

How to compile and install Apache PHP in the directory How to compile and install Apache PHP in the directory Mar 09, 2024 am 09:27 AM

How to compile and install ApachePHP in the directory requires specific code examples. Apache and PHP are two important tools often used in web development. Their compilation and installation can help us better customize and manage the server environment. This article will introduce in detail how to compile and install ApachePHP in the directory, covering specific code examples and step instructions. Step 1: Preparation Before starting, make sure you have the necessary compilation tools and dependencies installed on your system. Normally, the following