当前位置:网站首页>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 .
边栏推荐
- Quatre méthodes de redis pour dépanner les grandes clés sont nécessaires pour optimiser
- Vulnerability discovery - vulnerability probe type utilization and repair of web applications
- DMA use of stm32
- Microservice resource address
- RT thread analysis - object container implementation and function
- 项目经理,你会画原型嘛?项目经理需要做产品设计了?
- RT thread analysis log system RT_ Kprintf analysis
- [try to hack] John hash cracking tool
- The IPO of mesk Electronics was terminated: Henan assets, which was once intended to raise 800 million yuan, was a shareholder
- Postman assertion
猜你喜欢
随机推荐
二叉树基本知识和例题
Postman断言
Postman Association
Dynamic programming (tree DP)
Project manager, can you draw prototypes? Does the project manager need to do product design?
[buuctf.reverse] 159_[watevrCTF 2019]Watshell
2021 RoboCom 世界机器人开发者大赛-本科组(复赛)
Summary of redis AOF and RDB knowledge points
DMA use of stm32
yolov5 tensorrt加速
Scala function advanced
Postman关联
Unity screen coordinates ugui coordinates world coordinates conversion between three coordinate systems
Application of Flody
Why does MySQL need two-phase commit
ORM aggregate query and native database operation
[buuctf.reverse] 159_ [watevrCTF 2019]Watshell
[mathematical modeling] differential equation -- sustainable development of fishing industry
I'd like to ask about the current MySQL CDC design. In the full volume phase, if a chunk's binlog backfill phase,
麥斯克電子IPO被終止:曾擬募資8億 河南資產是股東