关于编程技术的对话

      日志 2004-11-9 22:7
注: Matz 就是著名的编程语言 Ruby 的创始人(日本人)
这段对话翻译自 artima.com 网站对 Matz 的访谈的第四部分。

英文文章原址: www.artima.com/intv/craft.html

英文原文:
Bill Venners: In an interview with CIPS Connections, you said, "I read a bunch of open source software source code, for example, Perl, Python, and many flavors of Lisp interpreter. I know they were needed to write Ruby." What benefit do you think programmers can derive from reading source code?

Yukihiro Matsumoto: Programmers can get a lot of benefit from reading source code. You can't simply tell people how to be good programmers. You can offer them some principles of good programming. You can describe some good design experiences you've had. But you can't give them a real knowledge of how to be a good programmer. I believe the best way for that knowledge to be obtained is by reading code. Writing code can certainly help people become good programmers, but reading good code is much better.

Bill Venners: Why?

Yukihiro Matsumoto: Because being a good programmer is a matter of experience. Code is an expression of the thoughts, attitudes, and ideas of the programmer. By reading code, you can not only figure out what particular task the programmers were trying to accomplish and understand how they did it, but you can also gain insight into how they were thinking. This is the reason that reading code makes programmers better.

And besides that, if you want to know how to accomplish something in code, you can open a computer science textbook. The textbook will explain the algorithm. But if you want to understand the algorithm very quickly, reading code is the best way. Moreover, you can execute code that implements theh algorithm. You can use a debugger to watch the code as it performs the algorithm. And this is much better than just reading a textbook.

Learning Languages
Bill Venners: In the CIPS Connection interview, you gave ten tips for programmers. One of them was, "Learn more than one programming language, preferably many different styles, like scripting, object-oriented, functional, logic, etc." What is the benefit of learning multiple programming languages?

Yukihiro Matsumoto: Every language or system has its own culture. In the background of every language or system are some central ideas. Most of these ideas are good, but they are different. By learning many languages and systems, you get exposed to different ideas—and that enhances your point of view.

If you don't know Prolog, for example, you may not know the power of goal directed programming—programming by describing the problem to solve through specifying rules to apply. This is a very interesting concept. It is a very different way of thinking. And if you don't know Prolog, or the predicate logic, it's very difficult to discover this way of thinking by yourself. Knowing other systems and paradigms expands the world inside your brain. That's why I advise learning multiple languages


Bill Venners: You also said in your ten top tips: "Don't focus too much on tools. Tools change. Algorithms and basic fundamentals don't." What did you mean by that?

Yukihiro Matsumoto: That was partly about focusing on humans instead of machines. Humans change very slowly, but systems change rapidly. 100 years ago, people were mostly the same as they are in the present time. 100 years ago we had no computers. 50 years ago we had computers, but they were very primitive. 20 years from now, I can't imagine how computers will be. But I can imagine how people 20 years from now will think.

Another example is mathematics. Mathematics has a very long history. It's a very mature science, but computer science is not. So it's good to retrieve ideas from mathematics.

Tools change very easily as time passes. If you focus too much on present-day tools, your efforts will give you only short-term returns. If you want benefits that will endure, you need to focus more on fundamentals. Focus on mathematics and human psychology. Focus on established sciences and established ways of thinking.

Being Lazy
Bill Venners: You also mentioned in your ten top tips: "Be lazy. Machines should serve human beings. Often programmers serve machines unconsciously. Let machines serve you. Do everything you can to allow yourself to be lazy." Why should I try to be lazy?

Yukihiro Matsumoto: You want to be lazy. You want to do anything to reduce your work. I work hard to reduce my work, to be lazy.

Bill Venners: I believe that.

Yukihiro Matsumoto: I work very eagerly to be lazy.

Considering Interface
Bill Venners: You also mentioned in your ten top tips: "Be nice to others. Consider interface first: man-to-man, man-to-machine, and machine-to-machine. And again remember the human factor is important." What do you mean by, "consider interface first?"

Yukihiro Matsumoto: Interface is everything that we see as a user. If my computer is doing very complex things inside, but that complexity doesn't show up on the surface, I don't care. I don't care if the computer works hard on the inside or not. I just want the right result presented in a good manner. So that means the interface is everything, for a plain computer user at least, when they are using a computer. That's why we need to focus on interface.

Some software people—like weather forecasters, the number crunchers—feel that the inside matters most, but they are a very limited field of computer science. Most programmers need to focus on the surface, the interface, because that's the most important thing.

Bill Venners: You also mentioned machine-to-machine interfaces, so are you just talking about interfaces for users or also for machines?

Yukihiro Matsumoto: It's not just user interfaces. When machines are talking to each other via a protocol, they don't care how the other is implemented on the inside. The important thing is the proper output getting passed correctly via the proper protocol. That's what matters.

If you have a good interface on your system, and a budget of money and time, you can work on your system. If your system has bugs or is too slow, you can improve it. But if your system has a bad interface, you basically have nothing. It won't matter if it is a work of the highest craftsmanship on the inside. If your system has a bad interface, no one will use it. So the interface or surface of the system, whether to users or other machines, is very important.




关于技术

Bill Venners:
在一次CIPS Connections的交流中,你曾经说:” 我读过很多开放源码软件的源码,
例如,Perl,Python,和很多风格LISP解释器的源码,我知道在写Ruby 之前我应该了
解他们“ 你觉得程序员通过读源码可以得到哪些益处?

Yukihiro Matsumoto:
程序员通过读源码可以收益颇多。你无法简单的告诉别人如何成为一个好的程序员,你
可以向他们提供一些好的编程原则,你可以向他们描述一些你自己的一些好的设计经验,
但是你无法给予他们如果成为一个好程序员的实际知识。我相信获取这些实际知识的最
好方法就是读代码。写代码当然可以帮助你成为一个好的程序员,但是读代码这种方式
更好一些。

Bill Venners:
为什么

Yukihiro Matsumoto:
因为成为一个好的程序员实际上是跟经验有关,代码是对程序员思想,态度,想法的表
达。通过读代码,你不仅可以了解程序员要完成一个什么特殊的任务以及知道他们是如
何实现的,而且你也可以通过他们的思考方式而增长见识。这就是为什么读程序可以让
你成为更好的程序员的原因。
除此之外,如果你想知道如何用代码实现一些东西,你可以打开一本计算机科学方面的
书籍,书本可以向你解释算法,但是如果你想更快的了解算法,那么读代码将是最好的
方式。此外,你可以执行代码以实现算法。你可以在代码执行算法的时候使用一个调试
器来观察它。这种方式要远比读书本要好。



Bill Venners: 在CIPS Connection的交流中, 你给出了程序员的十个技巧。其
中之一是: ” 学不只一种程序语言,最好是不同风格的,比如脚本语言,面向对象语
言,函数式语言,逻辑式语言,等等“,学习多种程序语言有什么好处?

Yukihiro Matsumoto:
每个程序或者系统都有它自己的文化。每种语言或者系统都有自己的核心概念。这些
概念中大多数是好的,但是他们是不同的,通过学习多种语言和系统,你可以接受不
同的想法,进而增强你自己的观点。

例如,如果你不了解Prolog语言,你就不会了解目标指导性编程的威力
(通过应用指定规则描述要解决的问题来编程的方式)。这是一个非常有趣的概念,
是一种不同的思考方法。但是如果你不了解Prolog或者谓词逻辑的话,很难自己发现
这种思考方式。了解其他的系统和范式将会扩展自己头脑中的世界。这就是为什么我
极力推荐学习多种语言的原因

Bill Venners:
在你的十个最高技巧中你也说过:”不要太过多的关注于工具,工具是会变化的,而
算法和基本概念不会“,你这是什么意思。

Yukihiro Matsumoto:
部分是关于以人为本而不是以机器的观点。人的变化非常的慢,但是系统变化的非
常快。100 年前的人们和现在没什么太大的不同。 100 年前我们没有计算机,50
年前我们拥有了计算机,但是他们非常原始。从今之后的20年,我无法想象计算
机将会是什么样子的,但是我可以想象的出20年后的人们将会如何思考。

另外一个例子是数学。数学拥有非常悠久的历史。它是非常成熟的科学,但是计算
机科学不是。所以从数学中获取思想是非常好的。

工具会随着时间的流逝轻易的变化。如果你太多的关注现在的工具,那么你的努力只
能得到短期的回报。如果你想获得持久的收益,你应该更关注一些基础的东西。关注
数学和人类心理学。关注那些已经建立起来的科学和已经建立起来的思维方式。


懒惰:

Bill Venners:
你曾经在你的十大技巧中提到:”懒惰,机器将会服务于人类。经常程序员会不经意
的服务于机器。让机器服务于你。尽可能做哪些让你懒惰的事情“,为什么我们要设
法变得懒惰?

Yukihiro Matsumoto:
因为你想变得懒惰。你要做任何可以减轻自己工作的事情,我努力工作来减轻自己
的工作,变得懒惰。
Bill Venners:
我相信这点

Yukihiro Matsumoto:
我非常渴望变得懒惰。


考虑接口

Bill Venners:
你在十大技巧中也提到了:”对他人友好,首先考虑接口: 人对人,人对机器和机器
对机器的接口。再次记住人的因素是非常重要的 “ ,你这是什么意思,”首先考虑接
口?“

Yukihiro Matsumoto:
接口是我们作为一个用户所看到的一切。如果我的计算机正在内部做非常复杂的事情
,但是复杂性并没有表露在外面,我不在乎。我不在乎计算机是否在内部辛苦的工作。
我只要以好的方式呈现正确的结果。这就是说接口就是一切,至少对于普通的计算机
用户使用计算机的时候,情况就是如此,那就是为什么我们要关注接口的原因。

一些软件人士,比如天气预报员,数字计算者,他们更多的是了解事物的内部,但是
他们所处的是非常有限的计算机科学领域。大多数程序员需要关注表面,接口,因为
对他们来说那才是最重要的。

Bill Venners:
你也提到了机器对机器的接口,你的意思是不是仅仅是对用户的接口或者机器的接口

Yukihiro Matsumoto:
不只是用户接口。当机器之间通过一个协议互相对话的时候,他们不在乎对方内部是
如何实现的,最重要的是通过恰当的协议正确的传递恰当的结果,这才是最重要的。

如果你有的系统有一个好的接口,足够的时间和财务预算,你可以继续工作在你的系
统上。如果你的系统有错误或者是太慢,那么你可以改进它。但是如果你的系统有一
个糟糕的接口,那么你就基本上是一无所有了。内部实现有多高的技巧并不重要。如
果你的系统有一个糟糕的接口,没有人会使用它。所以接口或者系统的表面特征,无
论是对用户还是对其他机器来说,都是非常重要的。
标签集:TAGS:
回复Comments() 点击Count()

回复Comments

{commentauthor}
{commentauthor}
{commenttime}
{commentnum}
{commentcontent}
作者:
{commentrecontent}