编译器设计史 | 工作原理 | C 编译器简介

注:机翻,未校。
本文为 “编译器” 相关文章合辑。


History of Compiler Design

编译器设计的历史

Pritesh Pawar
Oct 20, 2021

In this blog I’ll be trying to shadow the history of compilers in detail along with the basic introduction to compilers and it’s optimization.
在这篇博客中,我将尝试详细介绍编译器的历史,以及编译器的基本介绍及其优化。

Starting with what a compiler is. A compiler is a computer program that translates a source program written in some high-level programming language (such as Java, Python) into machine code for some computer architecture (such as the Intel Pentium architecture, x86 AMD). The generated machine code can be later executed many times against different data each time. The common reason to use a compiler is to transform the source code into machine code and create an executable program.
从编译器是什么开始。编译器是一种计算机程序,它将用某些高级编程语言(如 Java、Python)编写的源程序转换为某些计算机体系结构(如 Intel Pentium 体系结构、x86 AMD)的机器代码。生成的机器代码可以在以后针对不同的数据多次执行。使用编译器的常见原因是将源代码转换为机器代码并创建可执行程序。

First Compiler 第一个编译器

Software’s for early computers was fundamentally written in machine code or in low level language like assembly language. Higher level programming languages were not invented until the benefits of being able to reuse software on different kinds of CPUs started to become significantly greater than the cost of writing a compiler. The very limited memory capacity of early computers also created many technical problems when implementing a compiler.
早期计算机的软件基本上是用机器代码或低级语言(如汇编语言)编写的。直到能够在不同类型的 CPU 上重用软件的好处开始明显大于编写编译器的成本,高级编程语言才被发明出来。早期计算机的内存容量非常有限,在实现编译器时也带来了许多技术问题。

Towards the end of the 1950s, machine-independent programming languages were first proposed. Subsequently, several experimental compilers were developed. The first compiler was written by Grace Hopper, in 1951, for the A-0 programming language. Grace Hopper coined the term “Compiler” which referred to her A-0 system which functioned as a loader or linker, not the modern notion of a compiler.
在 1950 年代末,独立于机器的编程语言首次被提出。随后,开发了几个实验性编译器。第一个编译器是由 Grace Hopper 于 1951 年为 A-0 编程语言编写的。Grace Hopper 创造了“编译器”一词,指的是她的 A-0 系统,它充当加载器或链接器,而不是编译器的现代概念。

The first Autocode and compiler in the modern sense were developed by Alick Glennie in 1952 at the University of Manchester for the Mark 1 computer. The FORTRAN team led by John Backus at IBM is generally credited as having introduced the first complete compiler in 1957. COBOL was an early language to be compiled on multiple architectures, in 1960. In many application domains the idea of using a higher level language quickly caught on. Because of the expanding functionality supported by newer programming languages and the increasing complexity of computer architectures, compilers have become more and more complex.
第一个现代意义上的 Autocode 和编译器由 Alick Glennie 于 1952 年在曼彻斯特大学为 Mark 1 计算机开发。由 IBM 的 John Backus 领导的 FORTRAN 团队被认为在 1957 年推出了第一个完整的编译器。COBOL 是 1960 年在多种架构上编译的早期语言。在许多应用领域中,使用高级语言的想法很快就流行起来。由于较新的编程语言支持的功能不断扩展,计算机体系结构的复杂性也越来越高,编译器变得越来越复杂。

img

source: realpython

Self Hosting Compilers

自托管编译器

In early days of compiler development, self hosting compilers were made. A compiler can be self hosted means it is written in programming language that it compiles, Building a self-hosting compiler is a bootstrapping problem, i.e. the first such compiler for a language must be either handwritten machine code or compiled by a compiler written in another language, or compiled by running the compiler in an interpreter.
在编译器开发的早期,出现了自托管编译器。编译器可以是自托管的,这意味着它是用它编译的编程语言编写的,构建一个自托管编译器是一个引导问题,即一种语言的第一个此类编译器必须是手写的机器代码,或者由用另一种语言编写的编译器编译,或者通过在解释器中运行编译器来编译。

  • Corrado Böhm PhD dissertation
    Corrado Böhm developed a language, a machine, and a translation method for compiling that language on the machine in his PhD dissertation dated 1951. He not only described a complete compiler, but also defined for the first time that compiler in its own language. The language was interesting in itself, because every statement (including input statements, output statements and control statements) was a special case of an assignment statement.
    Corrado Böhm 博士论文 Corrado Böhm 在他 1951 年的博士论文中开发了一种语言、一种机器和一种在机器上编译该语言的翻译方法。他不仅描述了一个完整的编译器,而且还首次用自己的语言定义了该编译器。该语言本身就很有趣,因为每个语句(包括 input 语句、output 语句和控制语句)都是 assignment 语句的特例。

  • NELIAC
    The Navy Electronics Laboratory International ALGOL Compiler or NELIAC was a dialect and compiler implementation of the ALGOL 58 programming language developed by the Naval Electronics Laboratory in 1958. NELIAC was the brainchild of Harry Huskey — then Chairman of the ACM and a well known computer scientist and supported by Maury Halstead. The earliest version was implemented on the prototype USQ-17 computer (called the Countess) at the laboratory. It was the world’s first self-compiling compiler — the compiler was first coded in simplified form in assembly language, then re-written in its own language and compiled by the bootstrap, and finally re-compiled by itself, making the bootstrap obsolete.
    NELIAC 海军电子实验室国际 ALGOL 编译器或 NELIAC 是海军电子实验室于 1958 年开发的 ALGOL 58 编程语言的方言和编译器实现。NELIAC 是 Harry Huskey 的心血结晶,Harry Huskey 当时是 ACM 的主席,也是一位著名的计算机科学家,并得到了 Maury Halstead 的支持。最早的版本是在实验室的原型 USQ-17 计算机(称为 Countess)上实现的。它是世界上第一个自编译编译器 — 编译器首先用汇编语言以简化形式编码,然后用自己的语言重写并由 bootstrap 编译,最后由自身重新编译,从而使 bootstrap 过时。

  • Lisp
    Another early self-hosting compiler was written for Lisp by Tim Hart and Mike Levin at MIT in 1962. They wrote a Lisp compiler in Lisp, testing it inside an existing Lisp interpreter. Once they had improved the compiler to the point where it could compile its own source code, it was self-hosting.
    Lisp 语言 另一个早期的自托管编译器是由 Tim Hart 和 Mike Levin 于 1962 年在 MIT 为 Lisp 编写的。他们用 Lisp 编写了一个 Lisp 编译器,在现有的 Lisp 解释器中对其进行了测试。一旦他们将编译器改进到可以编译自己的源代码的程度,它就是自托管的。

High Level Languages for System Programming

用于系统编程的高级语言

Compiler technology evolved from the need for a strictly defined transformation of the high-level source program into a low-level target program for the digital computer. The compiler could be viewed as a front end to deal with the analysis of the source code and a back end to synthesize the analysis into the target code.
编译器技术是从需要将高级源程序严格定义的转换转换为数字计算机的低级目标程序发展而来的。编译器可以看作是处理源代码分析的前端和将分析综合到目标代码中的后端。

Optimization between the front end and back end could produce more efficient target code. Early operating systems and software were written in assembly language. In the 1960s and early 1970s, the use of high-level languages for system programming was still controversial due to resource limitations. However, several research and industry efforts began the shift toward high-level systems programming languages, for example, BCPL, BLISS, B, and C.
前端和后端之间的优化可以产生更高效的目标代码。早期的操作系统和软件是用汇编语言编写的。在 1960 年代和 1970 年代初,由于资源限制,使用高级语言进行系统编程仍然存在争议。然而,一些研究和行业工作开始转向高级系统编程语言,例如 BCPL、BLISS、B 和 C。

  • BCPL (Basic Combined Programming Language) designed in 1966 by Martin Richards at the University of Cambridge was originally developed as a compiler writing tool.[17] Several compilers have been implemented, Richards’ book provides insights to the language and its compiler.[18] BCPL was not only an influential systems programming language that is still used in research[19] but also provided a basis for the design of B and C languages.
    BCPL(基本组合编程语言)由剑桥大学的 Martin Richards 于 1966 年设计,最初是作为编译器编写工具开发的。[17]已经实现了几个编译器,Richards 的书提供了对该语言及其编译器的见解。[18] BCPL 不仅是一种有影响力的系统编程语言,至今仍在研究中使用[19],而且还为 B 和 C 语言的设计提供了基础。
  • BLISS (Basic Language for Implementation of System Software) was developed for a Digital Equipment Corporation (DEC) PDP-10 computer by W.A. Wulf’s Carnegie Mellon University (CMU) research team. The CMU team went on to develop the BLISS-11 compiler one year later in 1970.
    BLISS(系统软件实现的基本语言)是由 W.A. Wulf 的卡内基梅隆大学 (CMU) 研究团队为数字设备公司 (DEC) PDP-10 计算机开发的。一年后的 1970 年,CMU 团队继续开发 BLISS-11 编译器。
  • Multics (Multiplexed Information and Computing Service), a time-sharing operating system project, involved MIT, Bell Labs, General Electric (later Honeywell) and was led b
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值