Scheme vs. Python

By guenchi at 2017-12-02 • 0人收藏 • 363人看过

People keep asking me about the choice of programming language in 61A. Here is a rather longer explanation than I could give face to face.


人们一直问我关于61A课程中编程语言选择的问题。相比于面对面的回答,这是一个相当长的解释。

 

1. The most important thing to understand: The choice of programming language is far from the most important thing in designing a course. The Berkeley party line is that you should be able to learn a programming language (after the first time) over a weekend. If we mean that, then we shouldn’t be arguing about the programming language so much. And we shouldn’t start designing a course by picking a programming language. Honestly, if the new Python-based course turns out to be a better course, I won't mind at all that it’s in Python. It's SICP that I want to preserve, not Scheme.


1.最重要的是要认识到:在一个课程的设计中编程语言的选择绝不是最重要的事。伯克利的指导思想是你可以用一个周末学会一门编程语言(在第一次课后)。如果理念是这样的,那么对于编程语言我们不需要争论那么多。甚至我们不应该以选择一门编程语言来开始设计一门课程。说实话,如果新的以Python为基础的课程被证明更好,我不在乎它是用Python讲的。我想保留的是SICP,而不是Scheme。


2. Having said that, something that is important to understand in designing a course is that the best language for a course is not necessarily the best language for writing real-world code. For writing real-world code, what you want is aggressive optimization, and access to libraries for up-to-the-minute solutions to real-world problems. For a course, what you want is a crystal-clear language that highlights the computer science ideas without hiding them in a cloud of syntax or library details.


2. 我们已经讨论过,我们需要认识的重点是,设计一门可能中用到的最佳的语言并非是我们在实际应用中用到的最佳语言。在现实的工作编码过程中,我们需要的是主动优化,通过调用库可以快速地解决现实问题。而对于一门课程,我们需要的是一个能清楚说明计算机科学理念的语言,而不是把这些理念隐藏在一堆语法或库里面。


3. And having said that, I’m not really ready to cede the real world to Python or Java. How many people reading this are 50 years old? Lisp is 50 years old — and for the most part, the lifespan of a programming language is closer to the lifespan of a dog than to that of a person. Only one other language (Fortran) is that old and still in use. Why has Lisp survived? Not because it’s useless. People still use it because you can write working code in Lisp way faster than you can in most so-called “practical” languages.


3. 我真的不准备把真实世界割让给Python和Java。阅读这篇文章的人有多少已经50岁了?Lisp已经有50年的历史了——要知道相比于人的寿命,大多数编程语言的寿命与狗的寿命更相近。除了Lisp,只有一种语言(Fortran)有那么长的历史并且仍在使用。为什么Lisp存活下来了?不是因为它没用。人们仍然在使用它,因为相比于大多数所谓的“实用”语言,你可以用Lisp的方式 更快地编写项目代码。


4. During those entire 50 years, people have been saying “Lisp is impractical”; “Lisp is too slow”; “procedure calling is too expensive”; “only professors care about Lisp.” They’re still saying it. But meanwhile, users — real users — who would never dare give their bosses a program written in Lisp are demanding Lisp’s ideas in the programming languages they do use. Today you take recursion for granted, but it was a radical idea when Lisp introduced it. (Fortran didn't have recursive procedures until fairly late in its history; the early personal computer users made do with BASIC, which, in those early versions, had no procedure calling at all.) Users of strongly typed languages demanded, and got, Lisp's heterogeneous lists. Today, the radical Lisp idea that's invading the mainstream is first class procedures. Guido van Rossum, the inventor of Python, hates Lisp, but he was dragged kicking and screaming by users into providing [a half-assed version of] lambda in Python. Even C++, a notorious can of worms, has added lambda in its most recent version. Lambda in Java is coming in 2013. In another decade they’ll probably discover first class continuations.


4. 在整个50年的历史里,人们一直在喷,“Lisp是不切实际的”,“Lisp太慢了”,“过程调用开销太大了”,“只有教授才关心Lisp”。他们直到现在还在喷。但是同时,那些从不敢向他们的老板提交Lisp程序的用户——真实的用户——在他们使用的编程语言中正需要Lisp的思想。今天你认为递归是理所当然的,但是当Lisp引入它时递归是一个激进的思想。(Fortran直到很晚才有了递归的过程;早期的个人电脑用户使用BASIC,在BASIC的早期版本中甚至连过程调用都没有。)强类型语言的使用者需要,而且得到了Lisp的异构列表。今天,正在侵入主流语言的Lisp思想是一级过程(first-class procedure)。Guido van Rossum,Python的发明者,痛恨Lisp,但是在用户的强烈要求下在Python中加入了(一个阉割版的)lambda表达式。甚至C++,一个臭名昭著的蠕虫(a notorious can of worms),也在最近的版本中加入了lambda表达式。Java中的lambda表达式会在2013年到来。在未来的十年中,人们可能会重新发现一级的续延(first-class continuation)。


5. You can learn to program in any language. But it’s not just an accident that the authors of SICP chose Scheme as their teaching language. The big ideas in the book — the ones that alumni in the real world tell us they’re using in their work — express themselves best in Scheme. Indeed, saying it that way puts the matter backward. Gerry Sussman (with Guy Steele) invented Scheme before he turned (with Hal Abelson) to expressing the ideas behind Scheme in a course. SICP is Scheme, in tutorial form.


5. 你可以学习任何一种语言。但是SICP课程的作者选择Scheme作为教学语言并不是意外。这本书的最重要理念——在现实工作中的校友告诉我们,使用Scheme能更好的表达他们的思想。实际上,他们这么说又把我们带回前面。Gerry Sussman(和Guy Steele)在他的课程当中阐述Scheme理念之前发明了Scheme。SICP是一门以Scheme为教学模式的课程。

登录后方可回帖

登 录
信息栏

Scheme中文社区

推荐实现 ChezScheme / r6rs / r7rs large
theschemer.org
Q群: 724577239

精华导览

社区项目

包管理器:Raven
HTTP服务器:Igropyr (希腊火)
官方插件:vscode-chez

社区目标:

完善足以使Scheme工程化和商业化的库,特别是开发极致速度的Web服务器和ANN模块。

一直以来Scheme缺少一个活跃的中文社区,同时中文资料的稀少,导致大多数因为黑客与画家和SICP而接触Scheme的朋友,在学完SICP后无事可做,不能将Scheme转换为实际的生产力。最后渐渐的放弃。
同时Chicken等实现,却因效率问题无法与其他语言竞争。本社区只有一个目的,传播Scheme的文明之火,在最快的编译器实现上,集众人之力发展出足够与其他语言竞争的社区和库。


友情链接:

Clojure 中文论坛
函数式·China


Loading...