编程语言与软件工程2016schemeworkshop.org编辑精选
编译器构造的增量式方法(2006)
An Incremental Approach to Compiler Construction (2006)
进阶 · 约 40 分钟读完前置知识:编译原理基础、汇编语言、Scheme/Lisp 基础
导读
这篇论文提出一种增量式编译器构造方法:从极小的语言子集开始,先做出能生成汇编并构建可执行文件的完整编译器,再逐阶段添加语言特性并扩展或修改编译 pass。其重点在教学设计——让学生尽早看到端到端流程,并持续讨论编译期与运行期的决策。
HN 关注点:这种增量教学法能否让新手第一周就得到可运行编译器,以及它选择 Scheme 是否绕过了 parsing、还有哪些相关教材和实现。
后来怎么样
该文提出的增量式编译器构造成为编译器课程的一种经典教学组织方式,后续出现了基于此思路的教材与课程(如 Essentials of Compilation)。它主要影响教学实践,而非工业编译器设计标准。
HN 评论精选
这几条评论里:质疑 1 补充 2 亲历 1
亲历作者基于该论文设计课程,赞赏第一周端到端和贯穿全流程讨论编译期/运行期决策。
我很喜欢这篇论文!我的编译器课程就是基于它的想法搭建的。增量方法非常棒:第一周就能得到一个生成汇编并构建出可运行二进制文件的程序。这首先具体展示了“编译器”是什么;其次,它为讨论静态与动态、编译期与运行期分别做哪些决策提供了很好的基础,而不需要完整实现。这些概念并不显然(例如未绑定标识符的检查何时能、何时应该做?除零、溢出或类型不匹配呢?),值得仔细教授和思考。课程因此可以每隔一两周从前到后增加一个新特性,并每次考虑它对整个流水线的影响。
jpolitz查看英文原文
I love this paper! I built my compilers course out of the ideas in it: https://www.cs.swarthmore.edu/~jpolitz/cs75/s16/index.html I think the incremental approach is terrific, because it allows you to get to a program the emits assembly and builds a working binary in week one. The first thing this does is give a concrete example of what "a compiler" is. The second is to provide a great foundation for discussing static vs. dynamic and what decisions are made at compilation time vs. runtime, without needing a full implementation. These concepts are not obvious (e.g. when can and should a check for unbound ids happen? What about divide by zero, or overflow, or type mismatch?), and deserve to be carefully taught and considered. This lets the course build up a new feature, from front-to-back, each week or two, and consider its implications on the whole pipeline each time.
质疑质疑选 Scheme 绕过 parsing,但赞成增量方法并推荐 Crenshaw 教程。
我觉得有点好笑:它声称“玩具编译器太简单,不能为新手编译器作者构建有用编译器做好准备”,然后却选择 Scheme,实际上绕过了整个解析过程……而我认为解析是写编译器一半的乐趣。递归下降的优雅(以及把它重构为表驱动的运算符优先级),还有它如何把表达式、语句块等递归结构变成线性指令序列,我认为每个写编译器的人都应该体验。不过,我同意增量方法,这并不新鲜;个人认为 Jack Crenshaw 的教程系列(始于1988)是最好的之一。有趣的是,Jack 并不专攻编译器,也不专攻计算机科学,但他的解释对我来说比许多专业人士清楚得多。
userbinator查看英文原文
I find it a little amusing that it claims "toy compilers are too simplistic and do not prepare the novice compiler writer to construct a useful compiler", and then chooses Scheme, effectively bypassing the whole process of parsing... which IMHO is half the fun of writing a compiler. Seeing the elegance of recursive descent (and refactoring it into table-driven operator-precedence) and how it can turn recursive structures like expressions and statement blocks into linear sequences of instructions is something I think everyone writing a compiler should experience. However, I agree with an incremental approach, and that is nothing new; personally I think Jack Crenshaw's tutorial series (started in 1988) is one of the best: http://compilers.iecc.com/crenshaw/ (original 68k version) http://www.pp4s.co.uk/main/tu-trans-comp-jc-intro.html (x86 version) It's interesting to note that Jack doesn't specialise in compilers, nor computer science for that matter, yet his explanations are far clearer to me than many of those who do.
补充补充印第安纳大学增量式编译教材作为相关资料。
也许相关:Essentials of Compilation: An Incremental Approach。Abdulaziz 提出增量方法,学生分阶段构建编译器;他们先为输入语言的极小子集实现完整编译器,之后每个阶段给输入语言加一个特性,并增加或修改 pass 来处理新特性。这是 Indiana University 增量版编译器课程的教材。
bsznjyewgd查看英文原文
Maybe related, Essentials of Compilation: An Incremental Approach: https://www.sharelatex.com/project/5637a774990f556d48bab667 "Abdulaziz proposed an incremental approach in which the students build the compiler in stages; they start by implementing a complete compiler for a very small subset of the input language, then in each subsequent stage they add a feature to the input language and add or modify passes to handle the new feature [...] This is the textbook for the incremental version of the compiler course at Indiana University"
补充将论文与 Chez Scheme 增量编译器和 nanopass 框架联系起来。
这是不是 Chez Scheme 那个增量式 40+ Scheme 编译器大作的前作?相关资源还有 nanopass framework。
616c查看英文原文
Is this preceding work to the tour de force that is the Chez Scheme incremental like 40+ Scheme compiler. I mean, Cisco bought it, probably to hide it from us all. It must be worth something. https://www.youtube.com/watch?v=Os7FE3J-U5Q http://lambda-the-ultimate.org/node/1589 https://github.com/akeep/nanopass-framework
相关资源
从这篇论文所有 HN 讨论帖的全部评论里整理出来的链接。
历次讨论
- 2016Hacker News 讨论帖157 分 · 19 评
同领域还值得读
Google 的软件工程(2017)
Software Engineering at Google (2017)
介绍了 Google 的软件工程实践,包括其单一代码库(monorepo)、几乎全部开发在主干进行而非分支、代码审查、构建系统 Blaze、协议缓冲区等工具与流程,并讨论了频繁重…
编程语言与软件工程2017 · 1,127 分 · 465 评 · 引用 15入门 · 约 45 分钟编辑精选Peter Naur:编程作为理论构建 (1985)
Peter Naur – Programming as Theory Building (1985)
Peter Naur 1985 年的经典论文《Programming as Theory Building》提出:编程的本质不是写代码或文档,而是在程序员头脑中构建对程序及其运行…
编程语言与软件工程2016 · 629 分 · 74 评入门 · 约 45 分钟编辑精选SciPy 1.0:Python 科学计算的基础算法
SciPy 1.0: fundamental algorithms for scientific computing in Python
这篇发表于 Nature Methods 的论文介绍了 SciPy 1.0——Python 科学计算生态的基石库,涵盖其核心算法模块(优化、积分、插值、线性代数等)、软件架构与社…
编程语言与软件工程2020 · 387 分 · 98 评入门 · 约 45 分钟编辑精选Lisp 的历史(1979)
History of Lisp (1979)
这是 Lisp 发明者 John McCarthy 于 1979 年为 HOPL(编程语言史)会议撰写的回顾文章,讲述 Lisp 的起源、设计动机与早期演进,文中也涉及 if 表…
编程语言与软件工程2018 · 352 分 · 44 评入门 · 约 45 分钟编辑精选使用 NumPy 进行数组编程
Array Programming with NumPy
这篇 Nature 文章介绍 NumPy 的数组编程模型及其在科学计算中的核心作用:以 ndarray 为中心,通过向量化操作让 Python 高效处理多维数组。
编程语言与软件工程2020 · 318 分 · 134 评入门 · 约 40 分钟编辑精选