当前位置:网站首页>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 .
边栏推荐
- [classic example] binary tree recursive structure classic topic collection @ binary tree
- The web project imported the MySQL driver jar package but failed to load it into the driver
- A blog to achieve embedded entry
- 力扣(LeetCode)186. 翻转字符串里的单词 II(2022.07.05)
- Platformio create libopencm3 + FreeRTOS project
- idea一键导包
- Unity screen coordinates ugui coordinates world coordinates conversion between three coordinate systems
- 几种RS485隔离通讯的方案介绍
- 集合详解之 Collection + 面试题
- Basic explanation of turtle module - draw curve
猜你喜欢

Crazy God said redis notes

你需要知道的 TCP 三次握手

Yolov5 tensorrt acceleration

比尔·盖茨晒18岁个人简历,48年前期望年薪1.2万美元

Use sentinel to interface locally

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

acwing周赛58

The IPO of mesk Electronics was terminated: Henan assets, which was once intended to raise 800 million yuan, was a shareholder

Class inheritance in yyds dry inventory C

Unity screen coordinates ugui coordinates world coordinates conversion between three coordinate systems
随机推荐
Ue5 small knowledge points to enable the setting of lumen
11. Intranet penetration and automatic refresh
Redis 排查大 key 的4种方法,优化必备
L'introduction en bourse de MSK Electronics a pris fin: 800 millions de RMB d'actifs de Henan étaient des actionnaires
Yyds dry goods inventory OSI & tcp/ip
从0到1建设智能灰度数据体系:以vivo游戏中心为例
ue5 小知识 FreezeRendering 查看视锥内渲染的物体
Chip debugging of es8316 of imx8mp
Unity screen coordinates ugui coordinates world coordinates conversion between three coordinate systems
Postman manage test cases
[detailed steps of FreeRTOS shift value for the first time]
[NOIP2009 普及组] 分数线划定
Platformio create libopencm3 + FreeRTOS project
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
几种RS485隔离通讯的方案介绍
A blog to achieve embedded entry
acwing周赛58
也算是学习中的小总结
How does vs change the project type?
麥斯克電子IPO被終止:曾擬募資8億 河南資產是股東