解释型和编译型编程语言

Every program is a set of instructions, whether it’s to add two numbers or send a request over the internet. Compilers and interpreters take human-readable code and convert it to computer-readable machine code.

每个程序都是一组指令,无论是添加两个数字还是通过Internet发送请求。 编译器和解释器将人类可读的代码转换为计算机可读的机器代码。

In a compiled language, the target machine directly translates the program. In an interpreted language, the source code is not directly translated by the target machine. Instead, a different program, aka the interpreter, reads and executes the code.

目标计算机以编译语言直接翻译程序。 在一种解释性语言中,源代码不会直接由目标计算机翻译。 而是由另一个程序(也称为解释器)读取并执行代码。

好的,但这实际上是什么意思? (Okay… but what does that actually mean?)

Imagine you have a hummus recipe that you want to make, but it's written in ancient Greek. There are two ways you, a non-ancient-Greek speaker, could follow its directions.

想象您有一个鹰嘴豆泥食谱要制作,但是它是用古希腊语写的。 作为非古希腊语讲者,您可以通过两种方式遵循其指示。

The first is if someone had already translated it into English for you. You (and anyone else who can speak English) could read the English version of the recipe and make hummus. Think of this translated recipe as the compiled version.

首先是有人已经为您翻译成英文。 您(以及其他会讲英语的人)可以阅读食谱的英文版本,做鹰嘴豆泥。 将此翻译的配方视为编译版本。

The second way is if you have a friend who knows ancient Greek. When you're ready to make hummus, your friend sits next to you and translates the recipe into English as you go, line by line. In this case, your friend is the interpreter for the interpreted version of the recipe.

第二种方法是,如果您有一位了解古希腊语的朋友。 当您准备制作鹰嘴豆泥时,您的朋友会坐在您旁边,并逐步将食谱翻译成英文。 在这种情况下,您的朋友是食谱解释版本的解释者

编译语言 (Compiled Languages)

Compiled languages are converted directly into machine code that the processor can execute. As a result, they tend to be faster and more efficient to execute than interpreted languages. They also give the developer more control over hardware aspects, like memory management and CPU usage.

编译的语言直接转换为处理器可以执行的机器代码。 结果,它们往往比解释语言更快,更高效地执行。 它们还使开发人员可以更好地控制硬件方面,例如内存管理和CPU使用率。

Compiled languages need a “build” step – they need to be manually compiled first. You need to “rebuild” the program every time you need to make a change. In our hummus example, the entire translation is written before it gets to you. If the original author decides that he wants to use a different kind of olive oil, the entire recipe would need to be translated again and resent to you.

编译语言需要一个“构建”步骤-首先需要对其进行手动编译。 每次需要进行更改时,您都需要“重建”程序。 在我们的鹰嘴豆泥示例中,整个翻译是在您到达之前编写的。 如果原始作者决定他要使用其他种类的橄榄油,则需要重新翻译整个食谱并重新发送给您。

Examples of pure compiled languages are C, C++, Erlang, Haskell, Rust, and Go.

纯编译语言的示例是C,C ++,Erlang,Haskell,Rust和Go。

口译语言 (Interpreted Languages)

Interpreters run through a program line by line and execute each command. Here, if the author decides he wants to use a different kind of olive oil, he could scratch the old one out and add the new one. Your translator friend can then convey that change to you as it happens.

口译员逐行执行程序并执行每个命令。 在这里,如果作者决定使用其他种类的橄榄油,则可以将旧的橄榄油​​划掉,然后添加新的橄榄油。 然后,您的翻译朋友可以随时将更改传达给您。

Interpreted languages were once significantly slower than compiled languages. But, with the development of just-in-time compilation, that gap is shrinking.

口译语言曾经远比编译语言慢。 但是,随着即时编译的发展 ,这种差距正在缩小。

Examples of common interpreted languages are PHP, Ruby, Python, and JavaScript.

常见解释语言的示例是PHP,Ruby,Python和JavaScript。

一个小警告 (A Small Caveat)

Most programming languages can have both compiled and interpreted implementations – the language itself is not necessarily compiled or interpreted. However, for simplicity’s sake, they’re typically referred to as such.

大多数编程语言可以同时具有编译和解释的实现-语言本身不一定是编译或解释的。 但是,为简单起见,通常将它们称为此类。

Python, for example, can be executed as either a compiled program or as an interpreted language in interactive mode. On the other hand, most command line tools, CLIs, and shells can theoretically be classified as interpreted languages.

例如,Python可以在交互模式下作为编译程序或解释语言执行。 另一方面,大多数命令行工具,CLI和外壳程序在理论上可以归类为解释语言。

的优点和缺点 (Advantages and disadvantages)

编译语言的优势 (Advantages of compiled languages)

Programs that are compiled into native machine code tend to be faster than interpreted code. This is because the process of translating code at run time adds to the overhead, and can cause the program to be slower overall.

编译为本地机器代码的程序往往比解释的代码要快。 这是因为在运行时翻译代码的过程增加了开销,并可能导致程序整体变慢。

编译语言的缺点 (Disadvantages of compiled languages)

The most notable disadvantages are:

最明显的缺点是:

  • Additional time needed to complete the entire compilation step before testing测试之前完成整个编译步骤需要额外的时间
  • Platform dependence of the generated binary code生成的二进制代码的平台依赖性

口译语言的优势 (Advantages of interpreted languages)

Interpreted languages tend to be more flexible, and often offer features like dynamic typing and smaller program size. Also, because interpreters execute the source program code themselves, the code itself is platform independent.

口译语言趋向于更灵活,并且经常提供诸如动态键入和较小程序大小的功能。 另外,由于解释器自己执行源程序代码,因此代码本身是平台无关的。

解释语言的缺点 (Disadvantages of interpreted languages)

The most notable disadvantage is typical execution speed compared to compiled languages.

与编译语言相比,最明显的缺点是典型的执行速度。

翻译自: https://www.freecodecamp.org/news/compiled-versus-interpreted-languages/

解释型和编译型编程语言

解释型和编译型编程语言_解释型和编译型编程语言:有什么区别?相关推荐

  1. 华数机器人编程语言_华数II型机器人控制系统.PDF

    华数II型机器人控制系统 华数II型机器人控制系统 产品简介 IPC-102控制器 主要特点: 华数II型机器人控制 1.基于工业IPC ,搭载实时 Linux操作系统 系统是华中数控为工业机 2.支 ...

  2. g++ linux 编译开栈_方舟编译器编译hello world踩坑全记录

    闲来无事,看到方舟编译器完整开源,于是打算拿来试着编译一个东西来,接下来把踩过的一些坑记录一下. 参考文档 方舟编译器的官网是 OpenArkCompiler​www.openarkcompiler. ...

  3. 解释什么是快速排序算法?_解释排序算法

    解释什么是快速排序算法? Sorting algorithms are a set of instructions that take an array or list as an input and ...

  4. 命令行编译java项目_命令行编译运行java工程(转)

    平时建立Java工程都是借助eclipse或intellij这些ide编辑器来构建,对于java工程的实际编译执行原理,从未了解过.作为一个曾经的C++程序员,对于源码刨根问底的那份执着从未丢过.于是 ...

  5. 创建型模式、结构型模式和行为型模式_设计模式之创建型模式

    设计模式GOF23(Group of Four) 设计模式可分为三种类型: 创建型模式:单例模式,工厂模式,抽象工厂模式,建造者模式,原型模式. 结构型模式:适配器模式,桥接模式,装饰模式,组合模式, ...

  6. python主流编程语言_对5种主流编程语言的吐槽!

    版权说明丨原文出处:微信公众号: Android每日学习 不可否认,想要成为一名优秀的程序员确实是需要掌握多种编程语言.通过这几年的自虐式学习,我也慢慢的掌握了这些编程语言.鬼知道这过程多么痛苦,但也 ...

  7. ant 编译java 项目_使用ant编译打包、部署简单的javaweb项目 --01

    目录结构: D:\code\kongee\ant_web_hello λ tree /f 卷 软件 的文件夹 PATH 列表 卷序列号为 000D-CD8E D:. │ .classpath │ .p ...

  8. 编程语言_如何正确地学习编程语言

    首先,当前学生和职场人学习编程已经成为了一个大的趋势,掌握编程语言不仅能够提升自身获取信息的能力,同时也能够拓展自身的能力边界,这一点在工业互联网时代会有更加明显的体现. 编程语言本身并不难,但是要想 ...

  9. 树莓派编译mysql卡死_关于树莓派编译工作空间卡死情况的解决办法

    我用的是买树莓派时官方带的SD卡16G,安装的时xubuntu桌面版.感觉运行还是比较流畅的,之前安装过ubuntu-mate.kubuntu.lubuntu.只有xubuntu是比较喜欢的. 在我安 ...

最新文章

  1. python建立数据库并搜索_如何建立一个简单的数据库,可供人在网络上进行搜索?...
  2. python数据分析可视化实例_Python数据分析及可视化实例之基于Kmean分析RFM进行用户关怀...
  3. 【flink】Flink源码编译:Flink1.11+版本编译及部署
  4. 又一国产数据库诞生!腾讯发布 TGDB,实时查询比 Neo4j 快 20-150 倍!
  5. H3C SecPath U200-S 如何在内网使用外网IP地址访问内网服务器
  6. Ruby 2.0 发布首个预览版
  7. java 进程 互斥锁_Linux 进程互斥锁 - Khan's Notebook GCC/GNU/Linux Delphi/Window Java/Anywhere - C++博客...
  8. 楼梯计算机公式,楼梯踏步数计算公式是什么
  9. Go语言发展状况和前景
  10. Unity Shader 一 激光特效Shader
  11. 计算机网络的最大优点,什么是计算机网络最突出的优点
  12. block与“阻塞(pend)”与“挂起(suspend)”的区别?
  13. ​《2020科技趋势报告》重磅发布,AI 和中国,成为未来科技世界关键词
  14. VScode主题字体(正体,斜体修改)
  15. Three.js显示物体的运动轨迹
  16. Python数据分析实战【十二】:机器学习决策树算法案例实战【文末源码地址】
  17. 服务器补丁卸载之后显示未副本,打印机无法删除,添加打印机一直变成副本,怎样删除?急需答案?...
  18. html毕业答辩ppt,毕业论文答辩PPT怎么写? 经验告诉你该这样
  19. [快讯]致铭主板促销免费赠送Q版暖水袋
  20. 日本老爷爷坚持17年用Excel作画,我可能用了假的Excel

热门文章

  1. 【蓝桥java】递归基础之39级台阶
  2. 【jquery】jquery基础知识
  3. 样式集(八)弹窗,规则弹窗,半透明弹窗
  4. Ant Design Pro 登录流程以及路由权限设置
  5. vue 点击事件执行多次
  6. mongodb索引--从55.7秒到毫秒级别
  7. iOS更改AppIcon
  8. Netty 之 Zero-copy 的实现(下)
  9. C#从数据库导出数据[excel]
  10. sublime text3 前端插件介绍