按年被提到
20072017 · 8 次2026
开源书›语言实现与理论·No.22

Let's Build a Compiler

动手写编译器
Jack W. Crenshaw

用 Pascal 一步步写出递归下降编译器的经典教程

免费阅读 ↗
被推荐 · 55 人首次 2007-10-04 · 最近 2026-05-10官方免费在线(版权保留,作者或出版社免费放出)
55不同的人
61活跃月份
39有推荐的月份
72讨论串

Jack W. Crenshaw 的系列教程,从最小的表达式解析器出发,每一章只加一点功能,逐步长成能生成汇编的完整小编译器。全程采用递归下降(recursive descent)和直接生成代码的做法,不依赖 lex、yacc 之类的自动工具,行文口语化、几乎没有形式化理论。代码用 Pascal 写成,年代较久,但思路可以搬到任何语言。和龙书这类系统教材相比,它更像边做边讲的实操手记,适合先建立信心再去读理论。

HN 为什么推荐它

HN 上的人把它当作编译器入门的首选推荐:认为它让编译器不再吓人,一步步跟着做就行,用什么语言实现都可以;也有人提醒它年代久、用 Pascal,但仍然有启发。

难度 2 / 5约 15 小时
适合谁

想亲手写第一个编译器的自学者

读之前最好知道
1基本编程能力
2递归(recursion)
3汇编语言基础概念

怎么读

由 Claude 根据这本书和 HN 上的说法整理,可能有错
  1. 1从头按章节顺序读,跟着敲代码,不要跳章
  2. 2用你熟悉的语言重写示例,不必拘泥于 Pascal
  3. 3读完再配合一本讲词法、语法分析和优化的教材补理论
  4. 4把它当第一本编译器读物,别指望覆盖类型系统和现代优化

HN 书评

推荐在前,同类按时间 · 每本最多保留 20 条,统计用全部提及 · 作者本人贴的不算
推荐bootload · 2008-11

“Comes in handy for learning how to write compilers ~ Let's Build a Compiler”

推荐它用来学写编译器
Memories of Turbo Pascal version 1.0原评论 ↗
推荐petercooper · 2008-12

“There's also Jack Crenshaw's classic "Let's Build A Compiler":”

补充推荐 Crenshaw 的这本经典
How Difficult is it to Write a Compiler?原评论 ↗
推荐chbarts · 2010-04

“it was just about perfect for someone who wanted to whip up a nice little compiler for a foogol on a late-1980s DOS box”

说对 1980 年代末在 DOS 上写小编译器的人几乎完美
Books Programmers Don't Really Read原评论 ↗
推荐mquander · 2010-06

“This is similar in spirit to this much more detailed series of text files, which is a great introduction for a beginner:”

称它是更详细的同类系列,适合初学者入门
An Incremental Approach to Compiler Construction原评论 ↗
推荐silentbicycle · 2010-10

“start with _Let's Build a Compiler_ - it'll make compilers seem much less intimidating.”

建议从它入手,让编译器不再那么吓人
Ask HN: Which compiler book to pick?原评论 ↗
推荐fusiongyro · 2012-11

“Even though it's very dated, Crenshaw's "Let's Build a Compiler" can teach you everything you need to get started building languages from scratch and by hand”

说它虽然很旧,仍能教会人从零手写语言
LuaJit 2.0 is out原评论 ↗
看全部 20 条 →
推荐groovy2shoes · 2013-02

“Jack Crenshaw's "Let's Build a Compiler" is a good introduction: Let's Build a Compiler”

推荐它作为编译器入门
Has Joel Spolsky Jumped the Shark? (2006)原评论 ↗
推荐shoo · 2013-05

“i found Jack Crenshaw's "Let's build a compiler" series a good starting reference and source of inspiration [1].”

说它是很好的入门参考和灵感来源
Let's build an entire programming environment around Brainfuck原评论 ↗
推荐arcft · 2013-11

“Also, this wonderful page too: Let's Build a Compiler”

补充推荐这个页面,一步步教写编译器且不用自动化工具
Join the Compiler Creation Club原评论 ↗
推荐vidarh · 2014-05

“If you want an imperative tutorial then the Crenshaw tutorial [1] or Nicklaus Wirth's book Compiler Construction[2] are great starting points.”

想学命令式教程,推荐它和 Wirth 的 Compiler Construction 作起点
Simple steps to implementing a programming language原评论 ↗
推荐sepeth · 2015-12

“A bit old and it is in Pascal, but still, Let's Build a Compiler by Jack Crenshaw is also fun to read:”

说它虽旧且用 Pascal,读起来仍然有趣
An Incremental Approach to Compiler Construction (2006) [pdf]原评论 ↗
推荐wilburTheDog · 2016-05

“Jack Crenshaw has a nice series called Let's Build a Compiler.”

推荐给没有 CS 学位的人入门编译器
Rich Programmer Food (2007)原评论 ↗
推荐userbinator · 2016-12

“personally I think Jack Crenshaw's tutorial series (started in 1988) is one of the best:”

认为这个教程系列是最好的之一
An Incremental Approach to Compiler Construction (2006) [pdf]原评论 ↗
推荐zachgersh · 2016-12

“Should be at least a good introduction to compilers.”

说它至少是不错的编译器入门
Ask HN: Recommend an introductory course on compilers原评论 ↗
推荐yati · 2017-02

“"Let's Build a Compiler"[1] by Jack Crenshaw is fantastic.”

称它非常棒
Ask HN: What are some books where the reader learns by building one project?原评论 ↗
推荐brudgers · 2017-07

“Crenshaw's classic Let's Build a Compiler is a great way to see how it was done even if it is written using Pascal.”

说虽然用 Pascal,仍是了解当年编译器怎么做的好办法
Show HN: Coffee++, idea for a language that compiles into C++原评论 ↗
推荐dawkins · 2017-09

“Hi, for the parser and compiler this helped me a lot: Let's Build a Compiler”

说它对自己写 parser 和编译器帮助很大
Ask HN: Resources for building a programming language?原评论 ↗
推荐zamalek · 2017-10

“I'm sure that someone who had never touched programming in their life could learn how to write a compiler from this work.”

相信从没写过程序的人也能靠它学会写编译器
Ask HN: What essay/blogpost do you keep going back to reread?原评论 ↗
推荐perlgeek · 2018-03

“It's an old classic, using somewhat outdated technologies, but there are more moderns versions floating around”

称它是老经典,技术有些过时,但有更现代的版本
Ask HN: “Write your own” or “Build your own” software projects原评论 ↗
推荐benhoyt · 2018-11

“There's also the (much older but still enlightening) "Let's Build a Compiler" by Jack Crenshaw:”

补充推荐这本更老但仍有启发的编译器入门
GoAWK: an AWK interpreter written in Go原评论 ↗