为什么我觉得编程就像施魔法一样?

摘至SCIP开篇
服务器君一共花费了208.874 ms进行了5次数据库查询,努力地为您提供了这个页面。
试试阅读模式?希望听取您的建议

心智的活动,除了尽力产生各种简单的认识外,主要表现在如下三个方面:

  1. 将若干简单的认识组合为一个复合认识,由此产生出各种复杂的认识;
  2. 将两个认识放在一起对照,不管它们如何简单或者复杂,在这样做时并不将它们合而为一;由此得到有关它们的相互关系的认识;
  3. 将有关认识与那些在实际中和它们同在的所有其它认识隔离开,这就是抽象,所有具有普遍性的认识都是这样得到的。

在大英百科全书关于“分类学理论”中提出,人类在认识和理解现实世界的过程中,普遍运用着三个构造法则:

  1. 区分对象及其属性,例如,区分一棵树和树的大小或空间位置。
  2. 区分整体对象及其组成部分,例如,区分一棵树和树枝。
  3. 不同对象类的形成及区分,例如,所有树的类和所有石头的类的形成和区分。

我们准备学习的是有关计算过程的知识。计算过程是存在于计算机里的一类抽象事物,在其演化进程中,这些过程会去操作一些被为数据的抽象事物。人们创建出一些称为程序的规则模式,以指导这类过程的进行。从作用上看,就像是我们在通过自己的写作魔力去控制计算机里的精灵似的。

一个计算过程确实很像一种神灵的巫术,它看不见也摸不到,根本就不是由物质组成的。然而它却又是非常真实的,可以完成某些智力性的工作。它可以回答提问,可以通过在银行里支付现金或者在工厂里操纵机器人等等方式影响这个世界。我们用于指挥这种过程的程序就像是巫师的咒语,它们是用一些诡秘而深奥的程序设计语言,通过符号表达式的形式精心编排而成,它们描述了我们希望相应的计算过程去完成的工作。

在正常工作的计算机里,一个计算过程将精密而准确地执行相应的程序。这样,初学程序设计的人们就像巫师的徒弟们那样,必须学习如何去理解和预期他们所发出的咒语的效果。程序里即使有一点小错误(常常被称为程序错误或者故障),也可能产生复杂而无法预料的后果。

幸运的是,学习程序的危险性远远小于学习巫术,因为我们要去控制的神灵以一种很安全的方式被约束着。而真实的程序设计则需要极度细心。需要经验和智慧。例如,在一个计算机辅助设计系统里的一点小毛病,就可能导致一架飞机或者一座水坝的灾难性损毁,或者一个工业机器人的自我破坏。

软件工程大师们能组织好自己的程序,使自己能合理地确信这些程序所产生的计算过程将能完成预期的工作。他们可以事先看到自己系统的行为方式,知道如何去构造这些程序,使其中出现的意外问题不会导致灾难性的后果。而且,在发生了这种问题时,他们也能排除程序中的错误。设计良好的计算系统就像设计良好的汽车或者核反应堆一样,具有某种模块化的设计,其中的各个部分都可以独立地构造、替换、排除错误。

The acts of the mind, wherein it exerts its power over simple ideas, are chiefly these three: 1. Combining several simple ideas into one compound one, and thus all complex ideas are made. 2. The second is bringing two ideas, whether simple or complex, together, and setting them by one another so as to take a view of them at once, without uniting them into one, by which it gets all its ideas of relations. 3. The third is separating them from all other ideas that accompany them in their real existence: this is called abstraction, and thus all its general ideas are made.

We are about to study the idea of a computational process. Computational processes are abstract beings that inhabit computers. As they evolve, processes manipulate other abstract things called data. The evolution of a process is directed by a pattern of rules called a program. People create programs to direct processes. In effect, we conjure the spirits of the computer with our spells.

A computational process is indeed much like a sorcerer's idea of a spirit. It cannot be seen or touched. It is not composed of matter at all. However, it is very real. It can perform intellectual work. It can answer questions. It can affect the world by disbursing money at a bank or by controlling a robot arm in a factory. The programs we use to conjure processes are like a sorcerer's spells. They are carefully composed from symbolic expressions in arcane and esoteric programming languages that prescribe the tasks we want our processes to perform.

A computational process, in a correctly working computer, executes programs precisely and accurately. Thus, like the sorcerer's apprentice, novice programmers must learn to understand and to anticipate the consequences of their conjuring. Even small errors (usually called bugs or glitches) in programs can have complex and unanticipated consequences.

Fortunately, learning to program is considerably less dangerous than learning sorcery, because the spirits we deal with are conveniently contained in a secure way. Real-world programming, however, requires care, expertise, and wisdom. A small bug in a computer-aided design program, for example, can lead to the catastrophic collapse of an airplane or a dam or the self-destruction of an industrial robot.

Master software engineers have the ability to organize programs so that they can be reasonably sure that the resulting processes will perform the tasks intended. They can visualize the behavior of their systems in advance. They know how to structure programs so that unanticipated problems do not lead to catastrophic consequences, and when problems do arise, they can debug their programs. Well-designed computational systems, like well-designed automobiles or nuclear reactors, are designed in a modular manner, so that the parts can be constructed, replaced, and debugged separately.

本文地址:http://www.nowamagic.net/librarys/veda/detail/1912,欢迎访问原出处。

不打个分吗?

转载随意,但请带上本文地址:

http://www.nowamagic.net/librarys/veda/detail/1912

如果你认为这篇文章值得更多人阅读,欢迎使用下面的分享功能。
小提示:您可以按快捷键 Ctrl + D,或点此 加入收藏

大家都在看

阅读一百本计算机著作吧,少年

很多人觉得自己技术进步很慢,学习效率低,我觉得一个重要原因是看的书少了。多少是多呢?起码得看3、4、5、6米吧。给个具体的数量,那就100本书吧。很多人知识结构不好而且不系统,因为在特定领域有一个足够量的知识量+足够良好的知识结构,系统化以后就足以应对大量未曾遇到过的问题。

奉劝自学者:构建特定领域的知识结构体系的路径中再也没有比学习该专业的专业课程更好的了。如果我的知识结构体系足以囊括面试官的大部分甚至吞并他的知识结构体系的话,读到他言语中的一个词我们就已经知道他要表达什么,我们可以让他坐“上位”毕竟他是面试官,但是在知识结构体系以及心理上我们就居高临下。

所以,阅读一百本计算机著作吧,少年!

《大话数据结构》 程杰 (作者)

《大话数据结构》主要内容包含:数据结构介绍、算法推导大O阶的方法;顺序结构与链式结构差异、栈与队列的应用;串的朴素模式匹配、KMP模式匹配算法;二叉树前中后序遍历、赫夫曼树及应用;图的深度、广度遍历;最小生成树两种算法、最短路径两种算法;拓扑排序与关键路径算法;折半查找、插值查找、斐波那契查找等静态查找;稠密索引、分块索引、倒排索引等索引技术;二叉排序树、平衡二叉树等动态查找;B树、B+树技术,散列表技术;冒泡、选择、插入等简单排序;希尔、堆、归并、快速等改进排序。

更多计算机宝库...