编程与软件工程purl.org编辑精选
Alan Kay 论“面向对象编程”的含义(2003)
Alan Kay on the Meaning of “Object-Oriented Programming” (2003)
2014 — 2019,它一次次回到首页
黑点是上首页(≥ 50 分)的那次投稿,空心点是没冲上去的投稿,点越大分数越高。
导读
这篇页面是 Alan Kay 2003 年的一封邮件回复,用来澄清他所说的“面向对象编程”原意:核心是消息传递、状态的局部保留与隐藏,以及极端的延迟绑定,而不是后来常被等同于的类、继承等机制。他提到这些想法可以在 Smalltalk 和 LISP 中实现,并批评了用 RPC 代替对象与消息来思考问题的倾向。
为什么经久不衰:今天多数 OOP 教学和实践仍围绕类与继承,而 Kay 的原意提醒人们消息传递和解耦才是关键,因此这篇短文反复引发讨论、至今值得读。
HN 评论精选
质疑消息传递与方法调用的本质区别,并追问异步、远程、语言实现等常见解释是否成立。
我还是不太理解,与普通方法调用相比,消息传递的核心思想到底是什么。它是要异步吗?实践中似乎并非如此。是要支持远程吗?方法调用也能远程。Objective-C 和 Ruby 这类语言在某种程度上算消息传递吗?为什么那叫消息传递而不是方法调用?本质区别是什么?Java 算消息传递吗?
chrisseaton查看英文原文
I still don't really understand what the big idea of message passing compared to a method call is. Is it supposed to be asynchronous? It never seems to be so in practice. It it supposed to be remotable? So are method calls. Are languages like Objective C and Ruby message passing to some extent? Why is that message passing rather than a method call? What's the essential difference? Is Java message passing?
批评 OOP 教学从动物/形状建模和外围机制入手,丢失了消息、状态隐藏、延迟绑定等核心。
我早年学 OO 编程时完全错过了 Kay 对 OOP 的这种提纯式概括——这不能怪我!我在 Java 专业编程里摸爬滚打五年后才意识到这些关键概念的重要性。更糟的是,大多数书和博客的 OO 入门教程都用试图用对象字面建模问题状态的例子(比如“动物”“形状”等)。我觉得教程和课程应该聚焦这些核心目标,并展示多态、继承等概念如何(或是否)服务于它们。现在常见的情况是,学生学了各种外围概念,却不知道它们要解决什么问题。
vishnugupta查看英文原文
"OOP to me means only messaging, local retention and protection and hiding of state-process, and extreme late-binding of all things. It can be done in Smalltalk and in LISP. There are possibly other systems in which this is possible, but I'm not aware of them." Such a pity that this filtered essence about OOP was lost on me during formative years of learning OO-programming; for no fault of mine! It took me half a decade into professional programming in Java to realize the importance of these key concepts. And the worse part is that most of the books/blogs start OO programming tutorial with examples that try to literally model the problem state using Objects (e.g., "Animals", "Shapes" etc.,). I guess tutorials, classes just focus on these key goals and show how concepts such as "polymorphism", "inheritance" etc., are work towards achieving (or not) them. What generally happens is that one is taught about all these peripheral concepts and students are left to wonder the problems they are trying to solve.
认为 OOP 被批评多因糟糕实现和 C++ 式继承滥用,其原意更接近松耦合、无共享状态的微服务。
近来很多对 OOP 的攻击源于 OOP 的糟糕实现,就像抨击设计模式更多是因为架构考虑不周和模式滥用。事实上,OOP 的起源基本上就是今天所说的微服务架构(受 CSP 启发的 Go 等语言是其特化)。每个服务可以按需有状态或无状态(不共享状态),服务之间应松耦合。这与大多数大型 OOP 架构相当不同,但在任何 OOP 语言里都可以按这种风格写。重度依赖继承来实现代码复用是完全另一类问题,与 OOP 关系不大,更多是 C++ 的影响。
robert_tweed查看英文原文
A lot of the recent trend towards OOP-bashing comes from bad implementations of OOP, just as bashing design patterns is more to do with badly thought out architectures and overuse of those patterns. In fact, the origins of OOP are basically what we would now call microservice architecture (CSP-inspired languages like Go being a specialisation of this). Each service can be as stateless or as stateful as it needs to be (without shared state) and services should be loosely coupled. That's quite different to most large-scale OOP architectures, but it is possible to code in that style in any OOP language. Heavy reliance on inheritance for code reuse is a whole problem class in itself that again has little to do with OOP and lots to do with the influence of C++.
追问 Kay 为何把 RPC 视为未理解对象/消息的思路,以及对象+消息相对 RPC 的区别。
接近结尾处:“但为了说明一个观念能多顽固地延续,整个七十年代和八十年代,有很多人试图用‘远程过程调用’来代替对对象和消息的思考。Sic transit gloria mundi(世间的荣耀就此消逝)。”有人能解释他在这里区分的到底是什么吗?RPC 有什么问题,而对象+消息解决了它?
pfraze查看英文原文
Towards the end: But just to show how stubbornly an idea can hang on, all through the seventies and eighties, there were many people who tried to get by with "Remote Procedure Call" instead of thinking about objects and messages. Sic transit gloria mundi. Can somebody explain to me what distinction he's drawing here? What's the issue with RPC that's solved by Objects+Messages?
历次讨论
同类还值得读
开源应用架构
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编辑精选