出版与作家生涯2016thorstenball.com
我为什么要写一本关于解释器的书
Why I wrote a book about interpreters
导读
这篇文章讲作者为什么写一本关于解释器的书:市面上同类材料要么理论过重,要么几乎不给代码示例,他想用循序渐进、配可运行代码的方式,让没有计算机科学背景的读者也能亲手实现一个解释器。对写作者来说,这是一个关于“找到内容空白、为特定读者降低门槛”的写作案例。
可以直接用的写作要点
- 01
动笔前先扫描同类作品,找出“太理论化”或“太浅”的空白,明确自己的书填补哪个位置。
- 02
把复杂主题拆成循序渐进的步骤,每一步都配上可运行的代码或具体例子,让读者边做边学。
- 03
用平实语言和具体命名(如“你刚刚写了一个解析器”)把抽象概念落到读者能感知的动作上。
- 04
先明确目标读者(业余爱好者、非科班),再据此决定理论深度与示例密度。
HN 评论精选
用编号步骤加一句“你刚写完了X”,把复杂概念拆成可操作的阶段,是极好的解释性写法。
我用最简洁的方式概括解释器和编译器:第一步,写一个程序,把输入程序读进一个精确表示该语言的数据结构——你刚写完了解析器。第二步,写一个程序,对第一步的数据结构进行操作以执行程序——你刚写完了解释器。第三步(可选),写一个程序,把第一步的数据结构转换成另一种能更高效解释的数据结构——你刚写完了优化器。第四步(可选),不断迭代第三步,直到优化器的输出是机器码——你刚写完了编译器。我不是说这就能取代这样一本书,只是我以前没这样想过,想把它记下来。
haberman查看英文原文
The way I would sum up interpreters and compilers, trying to put it as concisely as possible: Step 1. Write a program that reads the input program into a data structure that exactly represents the language. You just wrote a parser. Step 2. Write a program that operates on the data structure from (1) to execute the program. You just wrote an interpreter. Step 3 (Optional): Write a program that converts the data structure from (1) into a different data structure that you can interpret more efficiently. You just wrote an optimizer. Step 4 (Optional): Keep iterating on (3) until the output of your optimizer is machine code. You just wrote a compiler. Not saying the above obviates the need for a book like this one (at all), I just had never thought of it in quite this way and wanted to write it down. :)
自定节奏、反复观看能降低学习曲线;先熟悉术语,再谈理解。
我强烈推荐 Coursera 的编译课程:不必跟着班级进度,注册后按自己的节奏学,同一个视频看两三遍也行。这些东西其实没那么复杂,只是需要一点时间熟悉术语和概念。我用 Go 实现了完整的解析器、类型检查器和编译器(链接),后来又手写了一个递归下降解析器,纯粹为了好玩。
zellyn查看英文原文
I highly recommend the Coursera compilers class: you don't have to work though it in synch with a class; just sign up and work at your own pace. If you have to watch the same video two or three times, you can. None of this stuff actually turns out to be that complicated: it just takes a little while to get the lingo and concepts. I implemented the entire parser, typechecker, and compiler in Go here: https://github.com/zellyn/gocool I then went back and hand-wrote a recursive descent parser, just for fun: Cool is such a simple language that it really wasn't difficult.
好的技术写作要在理论与代码示例之间取得平衡,并循序渐进。
作者在做一件好事。正如他所说,这个题材的大多数文章要么理论极重,要么几乎没有代码示例。像 SICP 或 The Little Schemer 那样,用平易的语言把解释器一块块拆开讲,逐步给读者代码和理论,是个好主意。
nickpsecurity查看英文原文
[Ignoring the dupes since they got no attention. Good reason to resubmit if material is worthwhile.] The author seems to be doing a good thing. Like he said, most of the write-ups on this subject are either ultra-heavy with theory or basically nothing with code examples. Doing interpreters piece-by-piece like in SICP or The Little Schemer series in an accessible language gradually giving them the code and theory they need is a good idea. It could also help in my verifiable builds scheme where people show no subversion exist by building from ASM to small language (or interpreter) then to bigger one then whole compiler. I was debating p-code, Oberon, Scheme, MiniML... Biggest problem is that the best stuff, eg Scheme's or ML's, is least likely for imperative programmers to try to understand. Something like this could help if I use an imperative base.
目标读者应明确到“业余爱好者、非科班”,这直接决定写作难度。
除了重复发帖那件事,有人仔细看过这本书、能说说它是否适合初学者吗?我的意思是,没有计算机学位的人,能不能用它学习并用另一门语言实现一个解释器?编程是我的爱好,我的梦想是自己做一个解释器,但大多数书都太难懂了。
gekkonier查看英文原文
Except the dupe story, does anyone gave the book a closer look and can say if it's suitable for beginning programmers? By that I mean if it's suitable to study and implement an interpreter in other language without a degree in computer sience? Programming is one of my hobbies and my dream is to do an interpreter on my own, but most books are so heavy to understand if you know what I mean. Thank you very much for your opinion.
同类还值得读
写书:值得吗?
Writing a book: is it worth it?
Martin Kleppmann(《设计数据密集型应用》作者)复盘写书到底值不值:金钱回报低、耗时极长,但带来了可见度、信任和职业机会。
出版与作家生涯2020 · 642 分 · 287 评4 条写作要点编辑精选写书并不是个好主意
Writing books is not really a good idea
这篇文章讨论靠写书谋生的现实难度,评论区从版税数学、收入预期和写作目标三个角度补充了作者视角。
出版与作家生涯2021 · 577 分 · 609 评4 条写作要点编辑精选如何自助出版一本书:实用资源清单
How to self-publish a book: A handy list of resources
这是一份关于「如何自助出版一本书」的资源清单帖,涵盖从编辑、排版到 ISBN、销售渠道的实操工具与花费。
出版与作家生涯2018 · 558 分 · 88 评4 条写作要点编辑精选我自助出版一本Ruby on Rails书,赚了7万美元
How I Made $70k Self-Publishing a Book about Ruby on Rails
这是一篇 Ruby 开发者自述:他把一套 Rails 性能课程(书+视频+答疑)自出版,一年毛收入约 7 万美元,并总结了选题、定价、营销等经验。
出版与作家生涯2017 · 539 分 · 175 评4 条写作要点编辑精选石黑一雄警告年轻作家因“恐惧”而自我审查
Sir Kazuo Ishiguro warns of young authors self-censoring out of 'fear'
石黑一雄提醒年轻作者因“恐惧”而自我审查,即这条帖子讨论的核心。
出版与作家生涯2021 · 396 分 · 641 评5 条写作要点编辑精选