编程与软件工程lists.squeakfoundation.org编辑精选
Alan Kay:Smalltalk 的核心不是对象,而是消息传递(1998)
Alan Kay: Smalltalk is not about objects, it’s about messaging (1998)
2010 — 2019,它一次次回到首页
黑点是上首页(≥ 50 分)的那次投稿,空心点是没冲上去的投稿,点越大分数越高。
导读
这是 Alan Kay 于 1998 年在 Squeak 邮件列表中的一封回信,澄清 Smalltalk 的核心思想:它关注的不是'对象',而是'消息传递'——对象之间通过消息协作,就像互联网上节点间的通信。Kay 指出 OOP 的本意是封装的消息传递系统,而非类和继承的静态结构。
为什么经久不衰:它纠正了人们对 OOP 的普遍误解,几十年后仍是理解消息传递、Actor 模型等设计思想的一手源头。
HN 评论精选
用 Smalltalk 的 ifTrue 分支说明'计算即消息传递':对象本身就是计算机,消息是指令。
我认为 Smalltalk 的关键洞见可以从它的分支语句看出:`mybool ifTrue: [...]` 是把一个闭包作为 ifTrue 消息发给接收者 mybool。而 mybool 可以是任何东西——恰好有 true 和 false 两个对象满足这个'布尔接口',但你完全可以实现自己的对象替换它,外部代码无法分辨。这就是'计算即消息传递'的含义:每一步计算不是运行时在算,而是你的对象在算。对象就是计算机,消息就是发给这些计算机的指令!
derefr查看英文原文
I think the key insight of Smalltalk can be grasped just by thinking about how Smalltalk does branching. A line from the GNU Smalltalk tutorial: mybool ifTrue: [ ^ 2 / 4 roundup ] The outer part of this expression reads “send a closure expression, as the message ifTrue, to the receiver mybool.” Keep in mind, this `mybool` could be anything! It just so happens that there are two runtime objects, `true` and `false`, that satisfy the “Boolean interface” (consisting of messages ifTrue and ifFalse) the way you’d expect—with `true` running any closure passed in an ifTrue message, and `false` running any closure passed in an ifFalse message. (For those of you who know combinatory logic, these objects are essentially the K and SK combinators.) But consider that you can create your own object that implements this interface—with whatever arbitrary logic you like—and substitute it for a Boolean as the value of `mybool`, and no code will be able to tell the difference. This is what is meant by “computation as messaging.” Branching is a request to an opaque “branch-evaluating object.” At each step of computation, you’re not getting the runtime to compute—you’re getting your objects to compute. The objects are the computers, and the messages are the instructions to those computers!
消息的格式与时机决定了错误类型和复杂度,没有银弹,需按问题选择抽象层次。
我逐渐体会到消息格式(即媒介)对定义消息本身的重要性。消息的指定方式决定了你会遇到哪类错误和开发挑战:位置参数带来位置错误,命名参数则要定义更多类型。消息送达得越晚,就越需要携带自己的上下文;消息的作用域无界,复杂度也就无界。当然没有银弹——有时枚举值就够,有时元组更好,有时问题大到需要'消息里带一台小计算机',但那通常是为了给系统增加一层可编程性。
mntmoss查看英文原文
Something I have gotten more attuned to over time is the importance of the message format - i.e. the medium - in defining the message. That is, the way in which the message is specified changes the classes of errors and development challenges one might encounter. If function arguments are positional you get positional errors; if they are named you enter the business of defining many more types. Messages may return a different version of themselves(e.g. arithmetic) or a different category of message. The later in time the message is delivered, the more it has to carry around its own context. And when a message has unbounded scope it has unbounded complexity. And like with a lot of things, there aren't silver bullets. Many things can be defined as a single enumerated value. Sometimes tuples are nice, sometimes records are nice. Sometimes the problem expands to the point where you have to have a message with a little computer inside it - but when that happens it's usually not for the purpose of any specific task, it's to add a layer of programmability into the system.
提问:Actor 模型是否最接近 Kay 所说的消息传递思想。
有很多模型基于 Kay 的思想,但我感觉 Actor 模型(Carl Hewitt 提出)最接近 Kay 的本意。我理解得对吗?
thdrdt查看英文原文
There are so many models based on the ideas of Kay. But I got the feeling that the actor model (Carl Hewitt) is closest to what Kay meant. Am I right?
请求澄清 Kay 信中'元系统''二级架构''赋值的元层'等术语的含义。
希望有人能澄清 Kay 这几段话:'像互联网一样,必须允许多种超出任何单一标准的思想和实现'——指的是 HTTP 之外的协议,还是 HTTP 背后用各种语言写的服务器?'好的元系统能对对象使用的二级架构进行晚绑定'——什么是元系统、二级架构?还有'赋值是相对函数的元层变更,不应在同一层面处理'——这两个'元层'是什么意思?
jonahx查看英文原文
I'd love clarification on a few points, from anyone who understands everything Alan says here: Think of the internet -- to live, it (a) has to allow many different kinds of ideas and realizations that are beyond any single standard Is he referring here to alternative protocols from http, or to the fact that behind the single http protocol are servers written in myriad languages and styles? If you focus on just messaging -- and realize that a good metasystem can late bind the various 2nd level architectures used in objects What is a metasystem? Can you provide an example? Similarly, what are 2nd level architectures? the realization that assignments are a metalevel change from functions, and therefore should not be dealt with at the same level what does he mean here? what are the two "metalevels" of assignments vs functions? what are examples of other "metalevels"? i've just never heard these terminology in this context, so don't know where to start in understanding it...
历次讨论
同类还值得读
开源应用架构
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编辑精选