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

Crafting Interpreters

打造解释器
Robert Nystrom

动手实现两个完整解释器,从零讲清语言实现

免费阅读 ↗
被推荐 · 213 人首次 2017-01-17 · 最近 2026-10-25许可证 CC BY-NC-ND 4.0
213不同的人
103活跃月份
80有推荐的月份
254讨论串

Robert Nystrom 带读者从头写出同一门语言 Lox 的两个解释器:先用 Java 写树遍历版,再用 C 写字节码虚拟机。每一章都有完整代码和讲解,包括扫描、解析、变量、闭包、类和垃圾回收等。和偏理论的编译原理教材相比,它更动手,写法也轻松。网页版可免费阅读。

HN 为什么推荐它

HN 上的人把它当作入门语言实现的首选,称赞写得清楚、有趣,适合没有编译原理背景的人,也常和 Writing An Interpreter in Go 一起推荐。早年有人读的是未完成版,仍然给了很高评价。

难度 3 / 5约 50 小时开放许可
适合谁

想亲手写一门语言的程序员

读之前最好知道
1Java 或 C 语言
2递归(recursion)
3基本数据结构,例如哈希表(hash table)

怎么读

由 Claude 根据这本书和 HN 上的说法整理,可能有错
  1. 1从头开始,跟着每一章自己敲出代码,不要只复制
  2. 2先完成前半部分的树遍历解释器,再做字节码虚拟机
  3. 3每章末的挑战题值得做,能加深对语言特性的理解
  4. 4想看理论补充,可再配合一本编译原理教材

HN 书评

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

“For those of you that found this interesting, I also highly recommend: Writing An Interpreter in Go [1] and Crafting Interpreters [2].”

强烈推荐它作为字节码编译器和解释器的延伸阅读
Bytecode compilers and interpreters原评论 ↗
强烈推荐rhencke · 2019-09

“This is one of my favorite books(-in-progress) to follow along with. If you've ever even had a passing curiosity in how interpreters work, I highly recommend checking it out from the beginning”

强烈推荐,是最爱的跟读书,适合好奇解释器原理的人
Crafting Interpreters: Closures原评论 ↗
推荐yellowapple · 2017-01

“the Crafting Interpreters book is looking to be pretty helpful in getting me there: Crafting Interpreters”

觉得它对做一门可嵌入的小语言很有帮助
Pixie – A small, fast, native Lisp原评论 ↗
推荐msangi · 2017-02

“Crafting interpreters. It's still a work in progress, but the chapters published so far are very good.”

推荐它,已发布章节很好,边做解释器边学
Ask HN: What are some books where the reader learns by building one project?原评论 ↗
推荐scriptkiddy · 2017-04

“If you're into PL implementation, you can't go wrong with: (链接) or Crafting Interpreters or (链接)”

把它列为学习 PL 实现的可靠资源之一
Ask HN: Learn in weekend, what resources you suggest?原评论 ↗
推荐GarvielLoken · 2017-09

“But i am trying to work through it, it has good basic explanation.”

正在读,觉得它对编译器的基础讲解不错
My first fifteen compilers原评论 ↗
看全部 20 条 →
推荐ioddly · 2017-09

“Crafting Interpreters is coming along really nicely.”

称赞它进展顺利,可用来学写编程语言
Ask HN: Resources for building a programming language?原评论 ↗
推荐roknovosel · 2017-12

“I feel like a good place to share some of the resources I've compiled from HN regarding compilers/interpreters construction:”

把它列入自己整理的编译器和解释器构造资料
Writing a C Compiler, Part 2原评论 ↗
推荐werediver · 2018-03

“This is a new chapter of a wonderful open-source book by Bob Nystrom.”

介绍这本精彩开源书新出的表达式解析章节
Crafting Interpreters: A Bytecode Virtual Machine原评论 ↗
推荐herbstein · 2018-03

“And lastly there's Crafting Interpreters”

最后补充推荐它,用来自己动手写解释器
Ask HN: “Write your own” or “Build your own” software projects原评论 ↗
推荐otterpro · 2018-06

“I also recommend Robert Nystrom's book Crafting Interpreters for learning about interpreters. While it is still work-in-progress, the quality is great, and it is free to read online.”

推荐它学解释器,虽未完成但质量好且可免费在线读
The sequel to Writing an Interpreter in Go is coming this summer原评论 ↗
推荐Impossible · 2018-09

“Although its still in development, Crafting Interpreters (previously on HN (链接)) seems promising, and the existing content is good.”

虽仍在编写中,但内容不错,适合入门写编程语言
Ask HN: What's a starting point for learning how to write programming languages?原评论 ↗
推荐tomp · 2018-10

“there have been quite a few modern resources, even a few on HN IIRC!”

提到它是实现编程语言的现代资料之一
Ask HN: What's your favorite elegant/beautiful algorithm?原评论 ↗
推荐benhoyt · 2018-11

“Bob Nystrom's free online book Crafting Interpreters is excellent.”

称赞这本免费在线书出色,可用来学写解释器
GoAWK: an AWK interpreter written in Go原评论 ↗
推荐nprescott · 2018-11

“I've read more of Crafting Interpreters and really enjoy it, though it isn't yet finished.”

读了更多后很喜欢,虽然还没写完
GoAWK: an AWK interpreter written in Go原评论 ↗
推荐tyleo · 2019-06

“For anyone interested in additional material, the following link has also been shared on HN a few times: Crafting Interpreters”

补充推荐它作为额外资料,HN 上被分享过几次
Let's Build a Simple Interpreter. Part 14: Nested Scopes (2017)原评论 ↗
推荐garren · 2019-07

“[0], [1], [2] are easy to get started with and great to work through.”

认为这几份资料易上手,适合动手学,为编译器打基础
My First Fifteen Compilers原评论 ↗
推荐norswap · 2019-07

“In the save vein, I'm also going to recommend Crafting Interpreters It's a work in progress, but very well made.”

推荐它,虽未完成但做得很好
Let's Build a Compiler原评论 ↗
推荐TehShrike · 2019-08

“It's not finished yet, but you probably want Crafting Interpreters”

指出虽未完成,但想学编译器大概该读它
Build Your Own Text Editor原评论 ↗
推荐mamcx · 2019-09

“Real gems here.”

称赞这里有真正的宝藏,含实用的编译器实现示例
Ask HN: Compiler Engineers, what would you advise new grads/students to learn?原评论 ↗