编程与软件工程defmacro.org编辑精选
Lisp 的本质
The Nature of Lisp
2010 — 2020,它一次次回到首页
黑点是上首页(≥ 50 分)的那次投稿,空心点是没冲上去的投稿,点越大分数越高。
导读
这篇文章面向非 Lisp 程序员解释 Lisp 的本质:代码与数据同构,宏让程序可以操作和扩展自己的语法,而不只是调用库函数。它用待办事项等例子展示宏如何把代码当作数据来变换,并试图说明 Lisp 作为一种“可编程编程语言”的气质。
为什么经久不衰:它不纠缠括号语法,而是把 Lisp 的可扩展性和宏思想讲成一种可迁移的编程观,所以多年后仍值得读。
HN 评论精选
作者反对把 Lisp 学习描述成瞬间顿悟,认为它更像渐进式理解。
问题部分在于 Lisp 传教式宣传一开始就注定失败。它许诺瞬间的、令人目眩的顿悟——要不要再加份薯条?难道没听过不要用“这是史上最好笑的事”来开头讲笑话吗?我做 Lisp 好几年,写过几个解释器,却从未有过他描述的那种顿悟;小的领悟和面向对象设计、单元测试带来的差不多。几个月走下来,更像慢慢“吃透”,而不是禅宗顿悟。
akkartik查看英文原文
Part of the problem is that lisp evangelism sets itself up to fail. An instantaneous blinding moment of enlightenment, would you like fries with that? Haven't they heard that you shouldn't start a joke with "This is the most hilarious thing ever"? I've been doing lisp for several years now. I've built several interpreters. I've never had the enlightenment he describes. The minor epiphanies have been on par with oo design and unit tests. I've travelled far over the months, but it's closer to grok than zen.
vau 表达式可统一函数、宏和特殊形式,但实际应用仍少。
读到那篇讲用 Haskell 写 Lisp 解释器的相关文章,让我想起自己第二次“顿悟”——理解 vau 表达式。通常无法实现为函数的东西,往往需要控制参数求值(条件、赋值、短路布尔运算符等),于是语言加入特殊形式或宏来处理。但只要有能控制参数求值的构造,选择对所有参数求值就等价于函数;实现它后,编译器/解释器不必再区分函数、宏和内置形式,它们成了同一种东西。实际用途我了解的不多,但这可能只是缺少三十年集体经验;真正实现它的非玩具语言我只知道 Kernel。
gliese1337查看英文原文
Reading the related article on writing a Lisp interpreter in Haskell (http://news.ycombinator.com/item?id=4764088) reminded me of my second blinding moment of enlightenment- understanding vau expressions. Things that can't be implemented as functions are typically things that require controlling the evaluation of arguments (conditionals, assignment, short-circuiting boolean operators, etc.), and additional language features (built-in special forms or macros for writing your own) are included to handle those. But if you have something that allows you to control the evaluation of arguments, simply choosing to evaluate all your arguments gives the equivalent of a function. Implement that thing, and your compiler/interpreter no longer needs to know about the difference between functions and macros and built-in forms; they're all the same thing! There's not a lot of practical use for that kind of thing that I am aware of (implementing run-time macros is one, being able to pass short-circuiting boolean operators to map, reduce, etc. is another), but I strongly suspect that's just because we don't have 30 years of collective experience figuring out all of the great things about vau expressions like we have with Lisp and anonymous functions. The only language (discounting toy projects) I know of that actually implements them is Kernel (http://web.cs.wpi.edu/~jshutt/kernel.html).
这篇文章帮助读者真正理解 s-表达式,并把他们引向 Clojure;但内容需要现代化。
正是这个页面让我终于明白 Lisp 和 s-表达式为什么重要。大约一年前读完后,我拿起一本 Clojure 书,现在迷上了 s-表达式,只觉得自己入坑太晚。此前在 2003/04 年左右我试过 CLISP 教程,满篇数学例子、不讲哲学和设计,把我吓跑了;我从来不是被括号劝退,学了 ParEdit 后就回不去了。现在我想解释“为什么这么多括号”时就发这个链接。不过它有点过时,把 s-表达式和 JSON、JavaScript 联系起来可能更贴近当代读者;也许我该为现代开发者重写一篇。
Slackwise查看英文原文
This was the page that made me finally grasp why Lisp and s-expressions are relevant. After reading this about a year ago, I ended up picking up a Clojure book and now I'm enamored with s-expressions. I feel late to the party. The last time I tried to learn Lisp (prior to reading this) was in like 2003/4 from some CLISP tutorial that scared me away from having nothing but math examples and zero explanation of the philosophy or design. It felt like an esoteric and purely academic language, and I brushed it off as not worth my time. (I was never really put off by the parens, and now I love them. Never understood that aspect of Lisp discourse. Once you learn ParEdit[1] you don't want to go back.) Now I link this page whenever I want to explain to someone why there are "all these parens". It's dated, though, and associating s-expressions with JSON and JavaScript would probably be a more contemporary approach. Maybe I should rewrite this article for a modern developer audience. [1]: http://danmidwood.com/content/2014/11/21/animated-paredit.html "GIFs of ParEdit in action"
代码即数据带来宏安全和可写/可执行边界问题,Lisp 程序未必能自然解决。
“数据即代码、代码即数据”这一二元性中,一直让我不安的是安全层面。自从我们开始在文档里嵌入宏语言,就出现了各类安全问题;万维网之前宏病毒就大量存在,今天运行带宏的电子表格仍然危险。Lisp 如何应对现代“可写 XOR 可执行”的原则?还是说它根本应对不了?一个把自身 Lisp 特性暴露给用户的 Lisp 程序能安全吗(Emacs,说的就是你)?
brandmeyer查看英文原文
One of the aspects of the data-is-code and code-is-data duality that always bugged me surrounds security. Ever since we started embedded macro languages into documents, there have been classes of security problems around them. Even before the web there were macro viruses in abundance, and running spreadsheets with macros embedded in them is still a dangerous proposition today. How does Lisp deal with the modern Writable Xor Executable philosophy? Or does it? Can a lispy program that exposes its lispyness to its users be secure (emacs, I'm looking at you)?
历次讨论
同类还值得读
开源应用架构
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编辑精选