当前位置:网站首页>Simple understanding of interpreters and compilers
Simple understanding of interpreters and compilers
2022-07-06 04:54:00 【Gulu a mouthful of warm water】
About the difference between compiler and interpreter - EYES Group - Blog Garden (cnblogs.com)https://www.cnblogs.com/130701-EYES/p/5301555.htmlzz from http://www.cppblog.com/pengkuny/articles/23106.html
Cattle farm of Laifu and Wangcai
Laifu and Wangcai have one support Cattle farm . It was not too difficult to raise cattle , But their cows have special quirks . A yuan cow only eats grass cut into circles , And cow a Fang and a San ( From India ?) Eat separately and cut into squares And triangular grasses . If Laifu and Wangcai take grass that is not consistent with the cow's character to feed , o X They not only do not produce milk, but also despise Laifu and Wangcai .
So Laifu and Wangcai had their own ideas
Laifu's plan :
Laifu invented three sets of large crushers : Round crusher , Fangfang crusher and Sansan crusher . Grass is harvested every day , Put them into these three sets of machines and grind them for three cows . But once crushed , This pile of grass can only be eaten by a certain cow . Obviously, Afghanistan will not eat the grass prepared for ah yuan . And Laifu operates these three machines every day , I think it's troublesome .
Wangcai's plan :
Wangcai inspected the plan of Laifu , I found it really troublesome to operate three machines every day , And sometimes some cows can't finish , When some cows are not enough to eat , You can't mix crushed grass among cows . So Wangcai has different ideas : Mask type crusher .
As you can see in the picture , Wangcai equipped each cow with a mask crusher , So three cows can eat grass in one trough , Before eating, the mask will automatically crush the grass into a type suitable for the cow . Wangcai is easy , He only needs to mow the grass every day .
But Wangcai is despised ???
Yes , Be despised by Laifu . After observation, Laifu found , The efficiency of Wangcai's mask crusher is very low ( Because it's relatively small ). A yuan eats a lot , You'll be full in an hour after eating the food of Laifu's round crusher , But it takes ten hours to eat with a mask on ! So Laifu thinks that Wangcai's mask crusher is easy , But you can only feed calves , It's not suitable for cattle that eat a lot .
Wangcai also thinks it's a problem , But he doesn't want to go back to the Laifu plan , He improved the mask scheme : Forage pre cutter .
ha-ha , See what the pre cutting has done ? It cuts the grass smaller , Therefore, the need for a mask crusher to do much less .( Of course, the mask crusher should also be properly improved to suit the pre cut forage , So it is shown in blue ) A yuan used to eat masks for ten hours , Now it will take twoorthree hours .
Compiler and interpreter
well , Thank you for your patience to see here , After the above inappropriate example , I believe you have been quite confused . So let's try to go back to technology .
In the example above
forage grass = Our various programming languages ,C/C++/C#, Java, Pascal, PHP, Python, Perl, Java Script wait
cutting machine = Various compilers
cow = Various CPU( Don't tell me Intel and AMD Oh ), such as x86,ARM,MIPS wait
Then you should know why cows have a hobby of eating different shapes of grass , This strange metaphor is to express different CPU Accept different machine languages .
Corresponding to the cow diagram above , The diagram of the compiler is like this
The source code is compiled into machine code , stay CPU Up operation .
The interpreter is like this
Using the interpreter is very convenient , Just direct “ function ” Just fine , Don't look like C That way, there is the process of compiling links .
Why are these languages cross platform ? Because after you write the program , If there is an interpreter of this language on this platform , Just get it and run it directly on this platform . You can understand it as : The interpreter is in “ While compiling , While running ”, It just puts the compilation process manually done by programmers before when running the program .
Why do we generally say that the efficiency of the interpreter is relatively low ? You can also imagine , A program may be compiled many times when it runs in the interpreter , Because every time you run this program , Will be recompiled , This kind of expense is very big .
So was born Java,C# Such a precompiled language :
Before running , You need to manually compile the source code into intermediate code (Java It's called bytecode ), Then execute it in the interpreter .
This architecture avoids the overhead of compiling source code in the pure interpreter above , So it will be relatively efficient .
But I can't lie to you , Actually, I drew it in the pure interpreter Python,Perl,PHP It may not be really pure interpretation execution , This is really inefficient .Python It will generate become pyc Binary temporary file , It looks like the result of precompiling . Only JavaScript This really will not write too long language (Ajax Please forgive me ) Will adopt the pure interpretation of the operator type .
边栏推荐
- [noip2009 popularization group] score line delimitation
- The video in win10 computer system does not display thumbnails
- [classic example] binary tree recursive structure classic topic collection @ binary tree
- Embedded development program framework
- Postman管理测试用例
- Codeforces Round #804 (Div. 2)
- 从0到1建设智能灰度数据体系:以vivo游戏中心为例
- 8. Static file
- A little knowledge of CPU, disk and memory
- 组播和广播的知识点梳理
猜你喜欢
Basic knowledge and examples of binary tree
Leetcode dynamic planning day 16
GAMES202-WebGL中shader的编译和连接(了解向)
[lgr-109] Luogu may race II & windy round 6
RT thread analysis - object container implementation and function
Postman manage test cases
行业专网对比公网,优势在哪儿?能满足什么特定要求?
acwing周赛58
Vulnerability discovery - vulnerability probe type utilization and repair of web applications
Acwing week 58
随机推荐
Nestjs配置文件上传, 配置中间件以及管道的使用
Crazy God said redis notes
Quick sort
SQL injection vulnerability (MSSQL injection)
Complete list of common functions of turtle module
你需要知道的 TCP 三次握手
acwing周赛58
Microservice resource address
Leetcode 186 Flip the word II in the string (2022.07.05)
Delete subsequence < daily question >
关于imx8mp的es8316的芯片调试
Codeforces Round #804 (Div. 2)
The underlying structure of five data types in redis
动态规划(树形dp)
The web project imported the MySQL driver jar package but failed to load it into the driver
Canal synchronizes MySQL data changes to Kafka (CentOS deployment)
RTP gb28181 document testing tool
Upload nestjs configuration files, configure the use of middleware and pipelines
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
图论的扩展