Everybody in this country should learn how to program a computer… because it teaches you how to think.

---Steve Jobs

人都应该学习编程,因为它教人如何思考---乔布斯
deepstudy.net
深学汇
    
    
2017新年寄语给准备学习计算机的同学
来源:深学教育 | 作者:Botao Liu(深学教育海外技术顾问) | 发布时间: 2017-01-05 | 1522 次浏览 | 分享到:

    第一台数字计算机是1946年的214日在宾夕法尼亚大学完成的,但是并不是现在我们用的计算机的始祖。我们今天所使用的计算机几乎全部采用了相同的结构, 这个结构就是一匈牙利旅美数学家·诺依曼命名的,·诺依曼结构。 第一台·诺依曼结构的计算机是1951出品的UNIVAC,到现在不过65年。 65年来,计算机的结构基本没变化,只是集成度以每18个月翻倍的速度发展,微处理器晶体管的数量从当初的几千个迅速增长到几十亿个。从功能上说,计算机已经从当初只为国家机关做科学计算,发展到今天,计算机的应用已经深入到普通人的生活的每个角落,几乎成了人的一个人工器官。那么什么是·诺依曼模型呢?简单说就是规定了计算机的五大组成部分。

    第一部分运算器。简称CA 这是英文中央算术运算的缩写。

    第二部分控制器。简称CC 这是中央控制的缩写。

    部分存储器,简称M

    部分输入设备,简称I

    部分输出设备,简称O

    这五大部分连接形成一体。就构成了冯·诺依曼结构的计算机。 那么冯·诺依曼结构 除了说明计算机应该由这五大部分组成之外 还指出计算机的数据和程序均以二级制代码的形式,不加区别的存放在存储器中 存放的位置由存储器的地址指定。第三, 计算机在工作时能够自动的从存储器中取出指令加以执行。

     The Von Neumann architecture, which is also known as the Von Neumann model and Princeton architecture, is a computer architecture based on that described in 1945 by the mathematician and physicist John Von Neumann and others in the First Draft of a Report on the EDVAC. This describes a design architecture for an electronic digital computer with parts consisting of a processing unit containing an arithmetic logic unit and processor registers; a control unit containing an instruction register and program counter; a memory to store both data and instructions; external mass storage; and input and output mechanisms. The meaning has evolved to be any stored-program computer in which an instruction fetch and a data operation cannot occur at the same time because they share a common bus. This Draft of report suggests binary over decimal for the arithmetic system. This is referred to as the Von Neumann bottleneck and often limits the performance of the system.

 

    这里要澄清一个概念,不是因为发明了二进制才发明了计算机,而是采用了二进制是计算机的结构简单多了,实际上,·诺依曼提出他的计算机结构之前已经有电子计算机了,除了程序和数据区别对待,用人工通过输入,还是采用10进制的。那么我们来看看为什么二进制运算比10进制简单多了,10进制10个数字的加或减或乘,刨去0参与的,有81个结果,用电路实现非常复杂,而对二进制呢,1+1=0,1+0=1,用电路很容易实现。当然这只是一位,一位简单,其它位COPY就是了。计算机不怕繁琐,就怕复杂。

 

    在计算机发展早期,应用领域较窄,主要是科学与工程计算,处理对象是数值数据。一开始程序都是原始的二进制码, 都是0101,程序员输入程序,就是往机器里输入0101,对照一个码本,有点像电影里的谍报员,对照一个码本,把文字变成数字,数字用几长几短的电报码代替。这样编程非常辛苦,而且效率很低,后来计算机科学家就逐渐研究出接近人的自然语言的高级语言,然后让机器给编译车机器语言也就是0101码。1956年在J.Backus领导下为IBM机器研制出第一个实用高级语言Fortran及其翻译程序。此后,相继又有多种高级语言问世,从而使设计和编制程序的功效大为提高。这个时期计算机软件的巨大成就之一,就是在当时的水平上成功地解决了两个问题:一方面从Fortran及Algol60开始设计出了具有高级数据结构和控制结构的高级程序语言,另一方面又发明了将高级语言程序翻译成机器语言程序的自动转换技术,即编译技术。然而,随着计算机应用领域的逐步扩大,除了科学计算继续发展以外,出现了大量的数据处理和非数值计算问题。为了充分利用系统资源,出现了操作系统;为了适应大量数据处理问题的需要,开始出现数据库及其管理系统。软件规模与复杂性迅速增大。当程序复杂性增加到一定程度以后,软件研制周期难以控制,正确性难以保证,可靠性问题相当突出。为此,人们提出用结构化程序设计和软件工程方法来克服这一危机。软件技术发展进入一个新的阶段。出现了面向对象编程(OOP)的思想。

 

 编程的最大挑战是编写程序的逻辑,而不是定义数据。OOP的观点是我们最关心的是操作的目标,而不是操作他们需要的逻辑。这些目标可以是具有姓名和地址属性的人,也可以是一个大建筑物或小物件。

 

    The programming challenge was seen as how to write the logic, not how to define the data. Object-oriented programming takes the view that what we really care about are the objects we want to manipulate rather than the logic required to manipulate them. Examples of objects range from human beings (described by name, address, and so forth) to buildings and floors (whose properties can be described and managed) down to the little widgets on a computer desktop (such as buttons and scroll bars).

 

   OOP概念对编程的好处是:数据类可以被继承,使程序编码可共享可移植可调用,大大节省开发时间。同时也因为数据被包装在一个类里,一个类实型化后不容易被别的程序干扰,大大减少了程序出错的机会。

 

   The concepts and rules used in object-oriented programming provide these important benefits.

   The concept of a data class makes it possible to define subclasses of data objects that share some or all of the main class characteristics. Called inheritance, this property of OOP forces a more thorough data analysis, reduces development time, and ensures more accurate coding.

   Since a class defines only the data it needs to be concerned with, when an instance of that class (an object) is run, the code will not be able to accidentally access other program data. This characteristic of data hiding provides greater system security and avoids unintended data corruption.

   The definition of a class is reuseable not only by the program for which it is initially created but also by other object-oriented programs (and, for this reason, can be more easily distributed for use in networks).

 

   互联网出现之后,编程技术有了新发展,不再是单机的编程,又增加了对服务器的编程,对服务器的编程除了对服务器本身的编程,还要对客户端编程,以及服务器和客户端的交互编程。

   和单机编程一样,网络编程也经历了一个从混沌初开,什么都一锅烩的编程模式到集约化模块化的变迁,发展到今天,网络编程普遍采用了MVC结构:M是指模型,V是指外观,C是指控制器。把一个软件分成三部分-外观部分是客户端显示,V模型部分M用来分存储提取数据, 控制器C用来沟通沟通M和V,访问V,根据V的需要从M读取数据,送到V。MVC架构原本是为独立计算机设计的,互联网出现后,V的地位更明显了,因为V是远程客户端,包括显示和用户的键盘和鼠标输入,M指服务器的资源,如数据库。C指M和V之间的命令。 M和V之间的命令通常就是HTML码,javascript,ajax程序,数据通常用XML或JSON形式传递,HTML,javascript,ajax程序,本身是字符串, 客户端依靠浏览器平台或手机APP把这些字符串变成文字,图像和声音等。

 

   Model–view–controller (MVC) is a software design pattern for implementing user interfaces on computers. It divides a given software application into three interconnected parts, so as to separate internal representations of information from the ways that information is presented to or accepted from the user.

 

   Traditionally used for desktop graphical user interfaces (GUIS), this architecture has become popular for designing web applications and even mobile, desktop and other clients.

 

   As with other software architectures, MVC expresses the "core of the solution" to a problem while allowing it to be adapted for each system. Particular MVC architectures can vary significantly from the traditional description here.

 

   A typical collaboration of the MVC components.

The central component of MVC, the model, captures the behavior of the application in terms of its problem domain, independent of the user interface.

 

   The model directly manages the data, logic, and rules of the application.

A view can be any output representation of information, such as a chart or a diagram. Multiple views of the same information are possible, such as a bar chart for management and a tabular view for accountants.

The third part, the controller, accepts input and converts it to commands for the model or view.

 

   Interactions

   In addition to dividing the application into three kinds of components, the model–view–controller design defines the interactions between them.

 

   A model stores data that is retrieved according to commands from the controller and displayed in the view.

   A view generates new output to the user based on changes in the model.

A controller can send commands to the model to update the model's state (e.g., editing a document). It can also send commands to its associated view to change the view's presentation of the model (e.g., by scrolling through a document).

 

   Use in web applications

   Although originally developed for desktop computing, model–view–controller has been widely adopted as an architecture for World Wide Web applications in major programming languages. Several commercial and noncommercial web frameworks have been created that enforce the pattern. These software frameworks vary in their interpretations, mainly in the way that the MVC responsibilities are divided between the client and server.

 

 

   时至今日,计算机甚至可以自动生成一些成型俗套的程序,甚至比大多数程序员写的还好。那么人,或者说程序员还能干什么呢?

   那就是要有思想。人算术算不过计算机,现在甚至连下围棋也下不过计算机了,但是人类有想象,有情感。 虽然一个世界顶级的象棋大师和围棋九段都下不过计算机了,但是论综合能力,比如语言,识别和应对周边环境的综合能力要达到三岁儿童的能力还有非常长的距离。 回到程序员能干什么?是的,作为程序员,现在已经不需要你去记住当年那些程序员需要记住的程序指令,接口地址,甚至不需要你记住高级语言的语法和语句了,网上一搜就能拷贝,但是你必须知道需要做什么,通过什么编程手段实现。打个比方,在古代,一个将军需要亲自拿着兵器格斗,即使是到了宋朝,岳飞也得跃马持枪和金兀术拼,发展到清朝,虽然还是冷兵器作战,但是作为湘军统帅的曾国藩,已经不需要自己会拼杀了,他就是个书生,但是他必须懂如何带军队,懂如何部署军队。

   换回编程说,就是,编程技巧已经不重要,重要的是通观全局的综合能力和洞察问题的分析能力。 要写好计算机程序,思路必须很清晰,概念必须清楚,逻辑必须严谨,对运行程序的平台,平台之间的关系必须明了于心。至于编程语言,语法,语句,用多了了就记住了,用得少了就忘了,但是现在计算机能帮你查。所以这些都不是很重要的。

  


                                                                                                                   2017年元旦于圣路易斯