编程与软件工程paulgraham.com
T 的历史
History of T
2008 — 2018,它一次次回到首页
黑点是上首页(≥ 50 分)的那次投稿,空心点是没冲上去的投稿,点越大分数越高。
导读
Paul Graham 转载的 Olin Shivers 回忆文章《History of T》,讲述 1980 年代在耶鲁开发的 Lisp 方言 T 的历史:它引入词法作用域、强大的宏和可中断的实现等技术,以及围绕它的社区与人物(如 Guy Steele、CMU 的 Bliss 语言等)。文章兼具技术史与个人轶事,是了解 Lisp 方言演进的一手资料。
为什么经久不衰:它记录了动态作用域到词法作用域的关键转折和一段鲜为人知的 Lisp 方言史,几十年后仍是理解语言设计演进的经典读物。
HN 评论精选
Emacs Lisp 最终在多年后补上了词法作用域,印证了文章讨论的作用域之争。
应该指出的是,Emacs Lisp 现在也有了词法作用域。花了大约 30 年,但它终于来了。
melling查看英文原文
We should point out that Emacs Lisp now has lexical scope. It took about 30 years, but it's here. http://stackoverflow.com/questions/7654848/what-are-the-new-rules-for-variable-scoping-in-emacs-24
解释动态作用域与词法作用域的区别,并感慨词法作用域最终胜出。
作为一个非常年轻的程序员(我 35 岁),我几分钟前才第一次真正理解什么是动态作用域。维基百科的描述很糟糕,但 C2 wiki 的解释很精彩:动态作用域下,先在本地函数找变量,再沿调用栈向上找,所以同一个函数每次调用可能命中不同的变量。听起来完全不可思议,真不知道 80 年代的人怎么写出能用的软件。不过这也让我欣慰:人们常抱怨某项绝妙技术没流行起来,但事实证明绝妙技术有时确实会赢——比如词法作用域。向 Guy Steele 致敬!另外我意识到 shell 把环境变量复制给子进程,基本上就是动态作用域的当代例子。
skrebbel查看英文原文
Being an extremely young programmer (I'm 35), I had never quite understood what "dynamic scoping" is - the whole idea that scoping can somehow be done differently than "like in all the languages" was foreign to me until a few minutes ago. If you're an ignorant youth like me, here's some clarification. Wikipedia's description is horrid, but C2's[0] is a gem: "In dynamic scoping, by contrast, you search in the local function first, then you search in the function that called the local function, then you search in the function that called that function, and so on, up the call stack. "Dynamic" refers to change, in that the call stack can be different every time a given function is called, and so the function might hit different variables depending on where it is called from." Sounds totally insane to me and I wonder how people made working software at all in the '80s. That said, I get happy when I remember that people often complain about how horrible it is that $OBSCURE_AWESOME_TECHNOLOGY never made it and how $TRENDY_FAD solves the same problem so much less elegantly. I mean, apparently an $AWESOME_TECHONOLOGY sometimes does win, against all odds - in this case lexical scoping. Yay Guy Steele! http://wiki.c2.com/?DynamicScoping EDIT: I just realized that shells copying all environment variables into child processes is basically a present-day example of dynamic scoping (although, fortunately, without mutation - we'd have entire data centers on fire if you could mutate parent process envs). It gives me a slightly better idea how this stuff could be used to make working software.
作者亲历 T 编译器中断相关 bug 造成的诡异堆损坏,佐证文章所述可中断实现的难度。
T 的另一个实现壮举是允许在用户代码任意两条指令之间发生中断。这是目标,但 T3 编译器实际上有个极隐蔽的 bug,成为我职业生涯中处理过的最难的问题。我们在 JPL 用 T 写火星车和机械臂的研究代码,跑在 Solaris 和 vxWorks 两种机器上。嵌入式系统上随机崩溃,堆被大规模随机破坏,问题无法稳定复现,僵持了近一年。最后发现是栈指针在栈上还有活跃值时就被递减,两条指令顺序颠倒了。Solaris 上单线程用户态没事,但 vxWorks 没有受保护的内核地址空间,中断一打进来就出事。
lisper查看英文原文
> Another implementation feat of T's was that it allowed interrupts between any two instructions of user code. That was the goal, but the T3 compiler actually turned out to have a very subtle bug that manifested itself as the single hardest bug I have ever dealt with in my career. We used T to write research code for rovers and robotic arms at JPL. This code ran on two different machines: Sun3's running Solaris, and brandless embedded systems running vxWorks, but both running the same T compiler targeting the 68020 processor. On the embedded systems we would get random crashes, but the same code running on Solaris ran flawlessly. Post-mortems revealed massive and random heap corruption, so the crash was manifesting itself long after the root cause. Because the problem was random an could not be reliably reproduced, it was impossible to find the root cause. And that is how matters stood for nearly a year until someone (I don't remember who, but it wasn't me) finally figured out how to reproduce the problem reliably. Then I spent a couple of days single-stepping through machine code until I finally found the problem: the stack pointer was being decremented while a live value was still on the stack. That value was accessed by the very next instruction. Those two instructions were simply out of order. On Solaris this didn't matter because all the code ran in user space and was single-threaded. But vxWorks does not have a protected kernel address space. When an interrupt happens, that interrupt is processed on whatever process stack is currently active. So if you got an interrupt exactly between the stack pointer decrement and the subsequence load, the value was corrupted, and a few thousand instructions later everything would go kablooey.
借文中对 Bliss 的怀念质疑 C 是否只是被惯性锁定的局部最优。
“你还可以用 CMU 出的一种漂亮的、大致 C 级别的语言 Bliss 来给 -10 编程。我看到 C 就想起 Bliss,想哭。”我看到 C 时会想:这就是系统编程语言能做到的最好程度吗?也许 C 只是一个我们投入了太多人力、以至于无法再切换的局部最优解?
xradionut查看英文原文
"You could also program the -10 in a beautiful, roughly-C-level language from CMU, called Bliss. I see C and I remember Bliss, and I could weep." I see C and I wonder if that's the best we can do for a systems programming language. Maybe C is just a local optimum that we have just invested too much manpower into to switch to anything else?
历次讨论
同类还值得读
开源应用架构
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编辑精选