编程与软件工程info.ucl.ac.be编辑精选
写给傻瓜的编程范式:每个程序员都该知道的事(2009)
Programming Paradigms for Dummies: What Every Programmer Should Know (2009) [pdf]
2018 — 2021,它一次次回到首页
黑点是上首页(≥ 50 分)的那次投稿,空心点是没冲上去的投稿,点越大分数越高。
导读
这是 Peter Van Roy 的经典论文《给傻瓜的编程范式》,系统梳理了函数式、逻辑式、面向对象等主要编程范式及其背后的计算模型。作者主张不要为项目挑选单一语言,而应使用支持多种清晰分离概念的多范式语言,并为每个组件选择最简单够用的模型。
为什么经久不衰:它把“范式”拆解为可组合的正交语言概念,提出“最小表达能力原则”,这一框架至今仍是理解编程语言设计的绝佳入门。
HN 评论精选
介绍作者的核心思想:以正交概念构成计算模型,按最小表达能力原则为每个组件选最简单的模型。
我读过作者的书《CTM》。他其实不喜欢“范式”这个词,更愿意叫“计算模型”。模型是一组概念,概念是正交的语言特性,如闭包、并发、显式状态、异常等。他主张的不是为项目选一个最合适的范式语言,而是用支持多种清晰分离概念的语言,然后为每个程序组件选择最简单的概念集合。这就是“最小表达能力原则”:选择最简单(易于推理和做对)又能保持代码自然的模型。每个模型都有配套的编程技巧,如函数式的累加器、有状态并发的事务。不同模型的组件可以通过阻抗匹配混合使用,比如用序列化器把非并发组件接入并发程序。总之尽量用函数式,但如果程序需要可见的非确定性(如服务器),就没法只用函数式。
charlysl查看英文原文
I have read CTM, the author's book. He did in fact dislike the word "paradigm" and prefered "computation model" instead. A model is a set of concepts. A concept is an orthogonal language feature, like closures, concurrency, explicit state (which he now calls named state), exceptions, etc. His approach is not so much that you should select one language that supports a paradigm that seems the most suitable for a given project. Rather, what he advocates is that you should use a language that supports multiple cleanly separated concepts (close to what is called multiparadigm), and then you select the simplest set of concepts for each program component. This is the principle of least expresiveness, you should choose the simplest model (simple meaning that it is easy to reason about and to get right) that keeps the code natural (meaning there is little code unrelated to the problem at hand, little plumbing). Each model has an associated set of programming techniques, like accumulators for FP or transactions for stateful concurrency. It is possible to mix and match components that are written in different models by using impedance matching, which consists of creating an abstraction in the more expressive model that wraps the other component. An example would be a serializer, which allows you to plug a non concurrent component in concurrent program. Basically, you should use FP as much as you can, but you can't if your program needs, say, visible non-determinism, like a server in a client-server application. But then you can add just one concept, ports, to the declarative concurrent model, and you have a new model that allows a whole constellation of new programming techniques, the concurrent message passing model, Erlang-like. The non-determinism in this model is restricted to the ports, the only place where it's required, the rest of the program can still be functional. Other situations where FP might get stretched are when modularity or performance are a priority. This book helped me realize the whole FP vs OO debate is sterile, the ideal is to have a language that allows you to use FP in a natural way, and switch to, say, OO, in a natural way in some cases.
作者本人现身确认读者对论文细节的解读,并补充背景信息。
作为作者,我很享受你们对我论文的详细解读。顺便说一句,你们对那个大型 OOP 项目失败的猜测是对的。另外 Baskin Robbins 那个脚注是我和一位物理学家朋友之间的玩笑。这篇论文是 IRCAM 出版的计算机音乐书中的一章,那本书也值得一读。
pvanroy查看英文原文
As the author, I must say I really enjoyed your detailed comments and Biblical exegesis on my paper. FYI, your guess on the big OOP failure is correct. Also, the Baskin Robbins footnote is a joke between myself and a physicist friend. The paper is a chapter in a book on computer music published by IRCAM that is worth reading too. Keep up the good work!
提供论文背后的教材和配套在线课程链接。
相关资料:作者 2004 年的教科书《Concepts, Techniques, and Models of Computer Programming》,以及他在 edX 上的六周课程《Paradigms of Computer Programming – Fundamentals》。
randcraw查看英文原文
Relevant references... A 2004 textbook by the OP: Concepts, Techniques, and Models of Computer Programming https://www.amazon.com/Concepts-Techniques-Models-Computer-Programming/dp/0262220695 And his 6 week edX course: Paradigms of Computer Programming – Fundamentals https://www.edx.org/course/paradigms-of-computer-programming-fundamentals
对论文中未具名的“数十亿美元 OOP 失败项目”案例表示好奇。
论文在讨论继承时提到:80 年代一家大型跨国公司发起了基于 OOP 的宏大项目,尽管预算达数十亿美元,项目仍惨败,主要原因之一是错误使用继承。这说的到底是哪家公司?
sevensor查看英文原文
> We end our discussion of inheritance with a cautionary tale. In the 1980s, a very large multinational company initiated an ambitious project based on object-oriented programming. Despite a budget of several billion dollars, the project failed miserably. One of the principal reasons for this failure was a wrong use of inheritance. Who did that, exactly?
历次讨论
同类还值得读
开源应用架构
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编辑精选