编程与软件工程github.com编辑精选
Make a Lisp:动手实现一个 Lisp
Make a Lisp
2015 — 2021,它一次次回到首页
黑点是上首页(≥ 50 分)的那次投稿,空心点是没冲上去的投稿,点越大分数越高。
导读
Mal(Make a Lisp)是一个教学项目:用分步指南引导你从零实现一个 Lisp 解释器,并提供了 80 多种语言的参考实现,从 Bash、GNU Make 到 Rust、Haskell 都有。核心是一份循序渐进的指南,每一步只引入少量新概念。
为什么经久不衰:亲手写一个 Lisp 解释器是理解编程语言运行原理的经典练习,而这份分步指南和多语言实现让它成为跨越多年仍被反复推荐的学习资源。
HN 评论精选
称赞配套指南的文档质量极高
他的文档和教学思路是无价的。
agumonkey查看英文原文
His documentation and approach is priceless https://github.com/kanaka/mal/blob/master/process/guide.md
推荐类似的增量式学习路径,并提到 Ghuloum 的编译器构造论文
我喜欢它循序渐进、逐步推进的方式。我最喜欢的论文之一是 Ghuloum 的《增量式编译器构造方法》,它展示了如何用二十四个步骤构建一个真正的编译器——从简单的整数开始,逐步深入到更高级的主题。
nathell查看英文原文
I like how it takes an incremental, step-by-step approach. One of my favourite papers is Ghuloum's "An Incremental Approach to Compiler Construction" [1], which shows how to build not a mere interpreter, but a _compiler_ to actual machine code, in twenty-four steps, starting from simple integers and proceeding through more and more advanced topics. Shameless plug: I've been trying to follow along, but making it entirely self-contained and avoiding any additional tools. The result (in very early stages, currently dormant but not quite dead yet) is called Lithium [2]. [1]: http://scheme2006.cs.uchicago.edu/11-ghuloum.pdf [2]: https://github.com/nathell/lithium
用代码行数对比各语言实现的规模
惯例的 cloc 统计,看看哪些实现最短:Rust 3919 行、C 3356 行、Java 2872 行、Haskell 1951 行、Lua 1715 行……
codygman查看英文原文
Obligatory cloc reading to see which implementations were shortest: ------------------------------------------------------------------------------- Language files blank comment code ------------------------------------------------------------------------------- Rust 17 294 155 3919 C 18 446 383 3356 C# 19 472 235 3314 Visual Basic 17 322 131 2945 Java 17 322 134 2872 Go 17 299 147 2636 Bourne Shell 16 304 241 2308 Perl 19 263 165 2167 Haskell 17 328 99 1951 MATLAB 25 176 114 1880 Javascript 23 263 145 1873 PHP 17 242 118 1791 Scala 16 219 113 1731 Lua 18 227 87 1715 Python 18 218 143 1393 Ruby 17 165 87 1219 OCaml 15 105 98 1154 Clojure 17 247 117 1011 CoffeeScript 17 193 126 989 CSS 6 150 132 792 make 26 233 59 580 HTML 1 17 27 227 C/C++ Header 6 47 9 172 Maven 1 2 7 72 ------------------------------------------------------------------------------- SUM: 380 5554 3072 42067 -------------------------------------------------------------------------------
批评指南不够严谨,在纯函数式语言中实现尤其困难
我实现到了相当靠后的阶段,但不太推荐你照着做。指南写得比较潦草,没有明确每一步需要定义什么,比如 mal 值类型的各种情况,以及何时实现那些可选扩展。每种形式最多只有一句话解释,我几次以为自己实现对了,结果发现有明显实现里藏着细微的错误。另外,在纯函数式语言里写 Lisp 也不太顺手。
chc4查看英文原文
I got decently far in my implementation, but probably wouldn't suggest you use this. The actual guide is pretty sloppily written and doesn't outline all that much, along with not explicitly saying what you have to define at each step. It doesn't define what the different cases of the mal Lisp value type should be, for example, or when to implement pretty much all of the "optional" extensions it mentions in the first or second chapter. Most of the forms in each chapter get a sentence explanation of what they do, at most, and I hit several snags where I read an explanation and thought I implemented it correctly, only to find out there was something subtly wrong with the obvious implementation. Also, writing a Lisp in a purely functional language isn't the best :X Things like by-reference function environments and atoms are hard to implement if you're not Haskell, at least if you try in the method that the guide outlines...
认为这是极好的周末学习项目,TCO 实现简洁得出乎意料
这是消磨一个周末的绝佳方式,而且能学到非常多东西。它极其简单的尾调用优化(TCO)实现让我很惊讶。
falcolas查看英文原文
This is a fantastic way to "waste" a weekend, and there's so much learning to be had. The radically simple implementation of TCO really surprised me.
历次讨论
同类还值得读
开源应用架构
The Architecture of Open Source Applications
《开源软件架构》(AOSA)是一本在线免费书,邀请知名开源项目的作者亲自剖析其内部设计,涵盖 SQLAlchemy、LLVM、Audacity、Apache、Bash 等系统。
编程与软件工程上首页 9 次 · 2011–2024aosabook.org编辑精选编程语言简史:简短、不完整且多半错误
A Brief, Incomplete, and Mostly Wrong History of Programming Languages
一篇以戏谑、故意不准确的方式回顾编程语言史的博客文章,用夸张轶事和讽刺定义串起 Lisp、C、C++、Java、JavaScript、PHP 等语言。
编程与软件工程上首页 8 次 · 2009–2021james-iry.blogspot.comSQLite 是如何测试的
How SQLite is tested
SQLite 官方文档页,系统介绍 SQLite 的测试体系:多种测试方法(TCL 测试、模糊测试、回归测试、静态分析等)和海量测试用例,展示了这个小型开源项目如何靠极致测试获得…
编程与软件工程上首页 8 次 · 2009–2025sqlite.org编辑精选高级编程语言(2009)
Advanced programming languages (2009)
Matt Might 的经典文章,按用途推荐“高级编程语言”:如果追求就业就选主流语言,如果追求表达力、学术研究或创业,则推荐 Haskell、OCaml、Scala 等函数式语…
编程与软件工程上首页 8 次 · 2009–2022matt.might.net我的 Forth 与栈机器经历
Yosefk - My history with Forth & stack machines
作者以亲身经历回顾了使用 Forth 语言和栈式机器的历程:既赞叹其简洁优雅、代码量小、可自举的优点,也坦率指出栈操作在实际编程中的痛苦,以及 Forth 社区文化中的问题。
编程与软件工程上首页 8 次 · 2010–2024yosefk.com编辑精选