“For those of you that found this interesting, I also highly recommend: Writing An Interpreter in Go [1] and Crafting Interpreters [2].”
Crafting Interpreters
动手实现两个完整解释器,从零讲清语言实现
Robert Nystrom 带读者从头写出同一门语言 Lox 的两个解释器:先用 Java 写树遍历版,再用 C 写字节码虚拟机。每一章都有完整代码和讲解,包括扫描、解析、变量、闭包、类和垃圾回收等。和偏理论的编译原理教材相比,它更动手,写法也轻松。网页版可免费阅读。
HN 上的人把它当作入门语言实现的首选,称赞写得清楚、有趣,适合没有编译原理背景的人,也常和 Writing An Interpreter in Go 一起推荐。早年有人读的是未完成版,仍然给了很高评价。
想亲手写一门语言的程序员
怎么读
由 Claude 根据这本书和 HN 上的说法整理,可能有错- 1从头开始,跟着每一章自己敲出代码,不要只复制
- 2先完成前半部分的树遍历解释器,再做字节码虚拟机
- 3每章末的挑战题值得做,能加深对语言特性的理解
- 4想看理论补充,可再配合一本编译原理教材
HN 书评
推荐在前,同类按时间 · 每本最多保留 20 条,统计用全部提及 · 作者本人贴的不算“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”
“the Crafting Interpreters book is looking to be pretty helpful in getting me there: Crafting Interpreters”
“Crafting interpreters. It's still a work in progress, but the chapters published so far are very good.”
“If you're into PL implementation, you can't go wrong with: (链接) or Crafting Interpreters or (链接)”
“But i am trying to work through it, it has good basic explanation.”
看全部 20 条 →
“Crafting Interpreters is coming along really nicely.”
“I feel like a good place to share some of the resources I've compiled from HN regarding compilers/interpreters construction:”
“This is a new chapter of a wonderful open-source book by Bob Nystrom.”
“And lastly there's Crafting Interpreters”
“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.”
“Although its still in development, Crafting Interpreters (previously on HN (链接)) seems promising, and the existing content is good.”
“there have been quite a few modern resources, even a few on HN IIRC!”
“Bob Nystrom's free online book Crafting Interpreters is excellent.”
“I've read more of Crafting Interpreters and really enjoy it, though it isn't yet finished.”
“For anyone interested in additional material, the following link has also been shared on HN a few times: Crafting Interpreters”
“[0], [1], [2] are easy to get started with and great to work through.”
“In the save vein, I'm also going to recommend Crafting Interpreters It's a work in progress, but very well made.”
“It's not finished yet, but you probably want Crafting Interpreters”
“Real gems here.”