電腦

出自維基百科,自由嘅百科全書

Image:03wiki-zn-frontpage-icon.gif電腦仲翻譯緊。歡迎你積極翻譯同修訂

電腦係按照一系列指令(稱為程式)嚟處理數據嘅機器。

電腦用途廣泛。事實上,電腦係一種可以處理任何資訊嘅機器。根據邱奇-圖靈論題,即使係具有最極小能力嘅電腦,只要有足夠記憶體同時間,都可以完成下至PDA上至超級電腦等任意其他電腦嘅工作。因此,同樣嘅電腦設計不但可用於計算工資單,甚至亦可用於控制無人太空梭。當今電腦比起早期嘅設計無論係速度同數據處理量方面都要高好多。而根據摩爾定律,每隔幾年電腦嘅速度同數據處理量就會番一番。

電腦嘅外型有好多種,最初嘅電腦有成個電影廳咁大。而家咁大嘅電腦設備依然存在,而且專門用於科學計算同埋大公司所需嘅事務處理,呢種超級電腦通常稱為大型機。而個人使用嘅較為小型嘅電腦,稱為個人電腦,相應嘅便攜可移動電腦,稱為膝上型電腦。個人電腦及膝上型電腦係隨處可見嘅資訊處理同通訊工具,亦係廣大非專家概念中嘅“電腦”所指。不過,當今使用得最多嘅電腦其實係嵌入式電腦,一種用於控制各種設備嘅電腦,用嚟控制比如飛機、數碼相機等。

目錄

[編輯] 電腦嘅誕生

電腦嘅英文係computer,即係「計算機」。電腦嘅鼻祖包括 算盤 同 Antikythera mechanism (公元前八十七年希臘人用來計算行星運行嘅工具)。中世紀末期,歐洲數學同工程學又開始開花;一六二三年,Wilhelm Schickard就成功整咗第一部機械計數機。

一八二零年,Charles Babbage 第一個設計出可以編寫程式嘅計算機。不過由於嗰時技術有限,錢亦都唔夠,設計無即時實現到。之但係,一啲技術好似打窿咭同埋真空管,響十九世紀末證明咗喺電腦運算係好有用。Hermann Hollerith整咗部機器,可以自動處理大量打窿咭。

二十世紀頭半截,有好多科學運算要用到一啲好專門同精細嘅類比計算機。呢啲計算機,直接利用機械或電學來模擬問題。不過自從有咗可以寫程式嘅數碼計算機,就好少用到喇。

在30、40 年代,更強同靈活的計算設備連續建成,逐漸形成現代電腦嘅雛型,譬如1937年對數碼電子技術(由克勞德・沙朗發明) 同更靈活嘅編造程式性能,但是這並不代表"第一部電腦"已經誕生。呢段時期嘅成就有,Atanasoff-Berry Computer (1937),使用閥門(真空管)去計算二進制數字和保存記憶嘅機器;英國Colossus computer(1944),只能運行小量程式但可用閥門去重編程式;美國ENIAC (1946) - 第一真正地通用機器, 但仲用十進制和仍有固定結構使它每次使用均需再次輸入程式;以及Konrad Zuse's Z machines, 用機電Z3 (1941) 是第一部機器去執行二進制算術和程式。

負責起ENIAC個小組,睇到部機嘅瑕玼,就設計一個咗更加彈性,更好嘅架構,叫做咗記低程式架構(stored program architecture)。佢可以話係所有現代電腦嘅基礎。一九四零年代未,有唔少小組開始發展呢類電腦。第一部係響英國完成。第一部行得嘅叫小規模實驗機器(Small-Scale Experimental Machine),不過,第一部實用版就叫做EDSAC。

1950年代開始,由閥門推動嘅電腦投入服務,直至到佢地喺1960年代畀晶體管電腦取代為止。晶體管相比起閥門來講又細又快,而且價錢平啲,重更加可靠,結果晶體管就喺呢個優勢下被大量投入工業生産。到左1970年代,集成電路嘅採用令電腦能夠喺足夠低嘅成本下,使到大眾都可以擁有一部類似現今嘅電腦。

[編輯] 電腦原理

雖然電腦技術喺四十年代第一代通用電子電腦後已經發生咗好大嘅變化,不過大部分電腦仲喺用緊存儲程式架構(亦稱馮諾依曼架構,加因文中描述嘅主要發明人大概係ENIAC設計師J.Presper Eckert同John William Mauchly). 該設計令同用電腦成為現實。

該架構描述嘅電腦包括四部分:計算同邏輯單元(ALU), 控制單元,內存,輸入同輸出設備(統稱I/O). 呢啲部件被一捆線(bus)連住,一般由定時器或時鐘驅動(雖其他事件亦可驅動控制電路。

Conceptually, a computer's memory can be viewed as a list of cells. Each cell has a numbered "address" and can store a small, fixed amount of information. This information can either be an instruction, telling the computer what to do, or data, the information which the computer is to process using the instructions that have been placed in the memory. In principle, any cell can be used to store either instructions or data.

The ALU is in many senses the heart of the computer. It is capable of performing two classes of basic operations: arithmetic operations, the core of which is the ability to add or subtract two numbers but also encompasses operations like "multiply this number by 2" or "divide by 2" (for reasons which will become clear later), as well as some others. The second class of ALU operations involves comparison operations, which, given two numbers, can determine if they are equal, and if not, which is of greater magnitude.

The I/O systems are the means by which the computer receives information from the outside world, and reports its results back to that world. On a typical personal computer, input devices include objects like the keyboard and mouse, and output devices include computer monitors, printers and the like, but as will be discussed later a huge variety of devices can be connected to a computer and serve as I/O devices.

The control system ties this all together. Its job is to read instructions and data from memory or the I/O devices, decode the instructions, providing the ALU with the correct inputs according to the instructions, "tell" the ALU what operation to perform on those inputs, and send the results back to the memory or to the I/O devices. One key component of the control system is a counter that keeps track of what the address of the current instruction is; typically, this is incremented each time an instruction is executed, unless the instruction itself indicates that the next instruction should be at some other location (allowing the computer to repeatedly execute the same instructions).

Since the 1980s the ALU and control unit (collectively called a central processing unit or CPU) have typically been located on a single integrated circuit called a microprocessor.

The functioning of such a computer is in principle quite straightforward. Typically, on each clock cycle, the computer fetches instructions and data from its memory. The instructions are executed, the results are stored, and the next instruction is fetched. This procedure repeats until a halt instruction is encountered.

Larger computers, such as some minicomputers, mainframe computers, servers, differ from the model above in one significant aspect; rather than one CPU they often have a number of them. Supercomputers often have highly unusual architectures significantly different from the basic stored-program architecture, sometimes featuring thousands of CPUs, but such designs tend to be useful only for specialized tasks.

[編輯] 數碼電路

huh The conceptual design above could be implemented using a variety of different technologies. As previously mentioned, a stored program computer could be designed entirely of mechanical components like Babbage's. However, digital circuits allow Boolean logic and arithmetic using binary numerals to be implemented using relays — essentially, electrically controlled switches. Shannon's famous thesis showed how relays could be arranged to form units called logic gates, implementing simple Boolean operations. Others soon figured out that vacuum tubes — electronic devices, could be used instead. Vacuum tubes were originally used as a signal amplifier for radio and other applications, but were used in digital electronics as a very fast switch; when electricity is provided to one of the pins, current can flow through between the other two.

Through arrangements of logic gates, one can build digital circuits to do more complex tasks, for instance, an adder, which implements in electronics the same method — in computer terminology, an algorithm — to add two numbers together that children are taught — add one column at a time, and carry what's left over. Eventually, through combining circuits together, a complete ALU and control system can be built up. This does require a considerable number of components. CSIRAC, one of the earliest stored-program computers, is probably close to the smallest practically useful design. It had about 2,000 valves, some of which were "dual components", so this represented somewhere between 2 and 4,000 logic components.

Vacuum tubes had severe limitations for the construction of large numbers of gates. They were expensive, unreliable (particularly when used in such large quantities), took up a lot of space, and used a lot of electrical power, and, while incredibly fast compared to a mechanical switch, had limits to the speed at which they could operate. Therefore, by the 1960s they were replaced by the transistor, a new device which performed the same task as the tube but was much smaller, faster operating, reliable, used much less power, and was far cheaper.

Integrated circuits are the basis of modern digital computing hardware.

In the 1960s and 1970s, the transistor itself was gradually replaced by the integrated circuit, which placed multiple transistors (and other components) and the wires connecting them on a single, solid piece of silicon. By the 1970s, the entire ALU and control unit, the combination becoming known as a CPU, were being placed on a single "chip" called a microprocessor. Over the history of the integrated circuit, the number of components that can be placed on one has grown enormously. The first IC's contained a few tens of components; as of 2005, modern microprocessors such from AMD and Intel contain over 100 million transistors. Furthermore, The 45nm SRAM chip announced in 2006 by Intel has more than 1 billion transistors.

Tubes, transistors, and transistors on integrated circuits can be used as the "storage" component of the stored-program architecture, using a circuit design known as a flip-flop, and indeed flip-flops are used for small amounts of very high-speed storage. However, few computer designs have used flip-flops for the bulk of their storage needs. Instead, earliest computers stored data in Williams tubes — essentially, projecting some dots on a TV screen and reading them again, or mercury delay lines where the data was stored as sound pulses traveling slowly (compared to the machine itself) along long tubes filled with mercury. These somewhat ungainly but effective methods were eventually replaced by magnetic memory devices, such as magnetic core memory, where electrical currents were used to introduce a permanent (but weak) magnetic field in some ferrous material, which could then be read to retrieve the data. Eventually, DRAM was introduced. A DRAM unit is a type of integrated circuit containing huge banks of an electronic component called a capacitor which can store an electrical charge for a period of time. The level of charge in a capacitor could be set to store information, and then measured to read the information when required.

[編輯] 輸入/輸出設備

輸入/輸出設備,一般簡稱I/O (由英文input-output變化出來),係一切幫部電腦同另一部電腦或者外界溝通嘅設備嘅統稱。呢啲輸出可能係直接畀人睇嘅,亦都可以係畀另一部靠呢部電腦啲輸出來運作嘅電腦睇嘅。例如一個機械人嘅運算輸出就主要係畀佢自己啲手腳用。

相比起而家啲電腦,第一代電腦啲輸入同輸出設備就認真係有限公司。嗰陣時啲電腦靠punch card做輸入,將啲野質入個記憶體度做計算,然後用打印機將個計算結果印出來。值得一提嘅係,當時啲打印機多數係由電報機改装出來。咁多年來,科技發展令到電腦多左好多唔同嘅輸入輸出設備。好似而家啲個人電腦咁,鍵盤(keyboard)同埋滑鼠(mouse)就係最常用嘅輸入裝置,而螢光幕(display / monitor)就係最常用嘅輸出裝置。當然,好多時都會用到其他裝置,例如打印機、喇叭、同埋耳筒。其實而家嘅人用電腦仲有好多唔同方法做輸入,數碼相機就係一個輸入視訊嘅裝置。另外仲有兩種好舉足輕重嘅輸入輸出裝置,就係次級記憶裝置(secondary storage devices),例如硬碟(hard disk)、光碟(CD-ROM),同埋快閃記憶(key drives / flash memory),係一啲比較慢但係大容量嘅儲存裝置,畀人用來放資料遲啲攞番出來用;另一類就係用來接駁網絡,佢地賦予左電腦互相溝通嘅能力,令到電腦可以做嘅野多左好多。而家快速增長緊嘅互聯網將全世界每一部電腦連埋一齊,令電腦獲取資訊越來越方便。

[編輯] 指令

The instructions interpreted by the control unit, and executed by the ALU, are not nearly as rich as a human language. A computer responds only to a limited number of instructions, which are precisely defined, simple, and unambiguous. Typical sorts of instructions supported by most computers are "copy the contents of memory cell 5 and place the copy in cell 10", "add the contents of cell 7 to the contents of cell 13 and place the result in cell 20", "if the contents of cell 999 are 0, the next instruction is at cell 30". All computer instructions fall into one of four categories: 1) moving data from one location to another; 2) executing arithmetic and logical processes on data; 3) testing the condition of data; and 4) altering the sequence of operations.

Instructions are represented within the computer as binary code — a base two system of counting. For example, the code for one kind of "copy" operation in the Intel line of microprocessors is 10110000. The particular instruction set that a specific computer supports is known as that computer's machine language.

To slightly oversimplify, if two computers have CPUs that respond to the same set of instructions identically, software from one can run on the other without modification. This easy portability of existing software creates a great incentive to stick with existing designs, only switching for the most compelling of reasons, and has gradually narrowed the number of distinct instruction set architectures in the marketplace.

[編輯] 程式

電腦程式係一列畀電腦執行嘅指令,佢地可以由解決簡單問題嘅幾個指令去到一啲包含數據表既複雜指令。好多電腦程式包含數以百萬計既指令,當中大部分係重覆嘅,一部普通既電腦可以喺一秒內執行約三十億個指令(2005年)。一部電腦行得好快,唔係因為佢地可以執行一啲好複雜嘅指令,而係因為佢地識得根據編程員將好複雜嘅指令變成好簡單嘅程式語言之後好準確咁將佢地執行出來。

實際上,編程員唔會用機器語言(machine code)寫程式,因為咁寫程式會令到寫程式好困難,好無效率同埋好易出錯。雖然用程式語言寫程式都容易出錯,但係用機器語言寫程式要偵錯就真係難過登天。反之,編程員通常都會用一啲高等程式語言來寫程式,再用預先設計好嘅編譯器(compiler)或者直譯器(interpreter)將程式語言變成機器語言。有啲程式語言同機器語言好接近,例如比較低等嘅集合語言(assembly language);另一方面,Prolog之類嘅高等程式語言就係根據抽象原則建構出來,佢地嘅設計近乎無一絲同機器語言或者機器根底運作方法嘅關係。編程員選擇程式語言嘅時候通常根據工作本身需要、編程員本身實力同埋佢身邊可以用嘅工具來做決定。更加有啲時候,編程員用咩程式語言係取決於用家嘅需要,例如美國軍隊用嘅所有程式都要求編程員用Ada。

電腦程式有時又叫做軟件。軟件係一個比較含義廣泛嘅名詞,因為佢包函一切程式本身同埋幫助程式運作嘅數碼資訊。例如一個遊戲軟件就包括遊戲程式本身同埋好多圖像,音效等建立遊戲的虛擬環境的元素。一個電腦應用軟件通常透過零售途徑供給好多個用戶使用。一個典型嘅例子是一套由多種負責不同辨公室工作的程式組成的辦公室軟件。

積少成多,聚沙成塔,由一句程式碼發展成一個完整嘅應用程式,中間個過程真係覆雜到嘔白泡。就攞Firefox出來講丫,佢就係由二百萬行C++夾埋寫出來;佢已經唔算最勁,有啲程式嘅規模比佢更加大,由大大隊嘅編程員日以繼夜,嘔心瀝血咁磨出來。所以,完善嘅工作管理就成為左呢啲大單野成功嘅一大關鍵。程式語言同埋各種寫程式嘅技術令到工作可以斬件,不斷咁切細佢直至到每一個人嘅工作量都可以喺合理嘅時間內完成。

雖然有啲咁勁嘅野,軟件開發始終都仲係一個又慢、又易錯、結果又始料不及嘅行業。軟件工程學其實已經投放左好多資源研究點先可以令到生産過程更快、更準、更有效率,製成品更高質素。佢地嘅研究已經見到成果。

[編輯] 庫、操作系統

電腦發明左無耐之後,開始有人發現有一啲野原來每個程式都要用,例如各款數學函數。為提高效率起見,有人開始收集各種唔同人寫嘅函數,整成一個庫(library)。其中一種常見,發展得最快嘅係同輸入輸出裝置溝通嘅函數,因為佢地真係個個程式都唔少得。

By the 1960s, with computers in wide industrial use for many purposes, it became common for them to be used for many different jobs within an organization. Soon, special software to automate the scheduling and execution of these many jobs became available. The combination of managing "hardware" and scheduling jobs became known as the "operating system"; the classic example of this type of early operating system was OS/360 by IBM [5].

The next major development in operating systems was timesharing — the idea that multiple users could use the machine "simultaneously" by keeping all of their programs in memory, executing each user's program for a short time so as to provide the illusion that each user had their own computer. Such a development required the operating system to provide each user's programs with a "virtual machine" such that one user's program could not interfere with another's (by accident or design). The range of devices that operating systems had to manage also expanded; a notable one was hard disks; the idea of individual "files" and a hierarchical structure of "directories" (now often called folders) greatly simplified the use of these devices for permanent storage. Security access controls, allowing computer users access only to files, directories and programs they had permissions to use, were also common.

Perhaps the last major addition to the operating system were tools to provide programs with a standardized graphical user interface. While there are few technical reasons why a GUI has to be tied to the rest of an operating system, it allows the operating system vendor to encourage all the software for their operating system to have a similar looking and acting interface.

Outside these "core" functions, operating systems are usually shipped with an array of other tools, some of which may have little connection with these original core functions but have been found useful by enough customers for a provider to include them. For instance, Apple's Mac OS X ships with a digital video editor application.

Operating systems for smaller computers may not provide all of these functions. The operating systems for early microcomputers with limited memory and processing capability did not, and Embedded computers typically have specialized operating systems or no operating system at all, with their custom application programs performing the tasks that might otherwise be delegated to an operating system.

[編輯] 應用程式

The first digital computers, with their large size and cost, mainly performed scientific calculations, often to support military objectives. The ENIAC was originally designed to calculate ballistics-firing tables for artillery, but it was also used to calculate neutron cross-sectional densities to help in the design of the hydrogen bomb [6], [7], significantly speeding up its development. (Many of the most powerful supercomputers available today are also used for nuclear weapons simulations.) The CSIR Mk I, the first Australian stored-program computer, evaluated rainfall patterns for the catchment area of the Snowy Mountains Scheme, a large hydroelectric generation project[8]. Others were used in cryptanalysis, for example the first programmable (though not general-purpose) digital electronic computer, Colossus, built in 1943 during World War II. Despite this early focus of scientific and military engineering applications, computers were quickly used in other areas.

From the beginning, stored program computers were applied to business problems. The LEO, a stored program-computer built by J. Lyons and Co. in the United Kingdom, was operational and being used for inventory management and other purposes 3 years before IBM built their first commercial stored-program computer. Continual reductions in the cost and size of computers saw them adopted by ever-smaller organizations. Moreover, with the invention of the microprocessor in the 1970s, it became possible to produce inexpensive computers. In the 1980s, personal computers became popular for many tasks, including book-keeping, writing and printing documents, calculating forecasts and other repetitive mathematical tasks involving spreadsheets.

As computers have become less expensive, they have been used extensively in the creative arts as well. Sound, still pictures, and video are now routinely created (through synthesizers, computer graphics and computer animation), and near-universally edited by computer. They have also been used for entertainment, with the video game becoming a huge industry.

Computers have been used to control mechanical devices since they became small and cheap enough to do so; indeed, a major spur for integrated circuit technology was building a computer small enough to guide the Apollo missions [9] and the Minuteman missile [10], two of the first major applications for embedded computers. Today, it is almost rarer to find a powered mechanical device not controlled by a computer than to find one that is at least partly so. Perhaps the most famous computer-controlled mechanical devices are robots, machines with more-or-less human appearance and some subset of their capabilities. Industrial robots have become commonplace in mass production, but general-purpose human-like robots have not lived up to the promise of their fictional counterparts and remain either toys or research projects.

Robotics, indeed, is the physical expressions of the field of artificial intelligence, a discipline whose exact boundaries are fuzzy but to some degree involves attempting to give computers capabilities that they do not currently possess but humans do. Over the years, methods have been developed to allow computers to do things previously regarded as the exclusive domain of humans — for instance, "read" handwriting, play chess, or perform symbolic integration. However, progress on creating a computer that exhibits "general" intelligence comparable to a human has been extremely slow.

[編輯] 網路、網際網路

自1950年代,設喺唔同地方已經透過電腦去處理各種資料,例如美軍嘅SAGE系統就喺最大規模嘅電腦系統;而商業方面,則有Sabre等系統去服務不同嘅使用者。

到1970年代,美國ARPA資助各大學電腦工程師利用電訊科技將電腦連結起來,形成ARPANET系統。 The technologies that made the Arpanet possible spread and evolved. In time, the network spread beyond academic and military institutions and became known as the Internet. The emergence of networking involved a redefinition of the nature and boundaries of the computer. In the phrase of John Gage and Bill Joy (of Sun Microsystems), "the network is the computer". Computer operating systems and applications were modified to include the ability to define and access the resources of other computers on the network, such as peripheral devices, stored information, and the like, as extensions of the resources of an individual computer. Initially these facilities were available primarily to people working in high-tech environments, but in the 1990s the spread of applications like e-mail and the World Wide Web, combined with the development of cheap, fast networking technologies like Ethernet and ADSL saw computer networking become ubiquitous almost everywhere. 事實上,連結到網絡嘅電腦不斷大幅增加。好大比例嘅個人電腦習慣地同互聯網連接去交流同接收資料。

[編輯] 電腦職業、學科

喺已發展社會,每個行業都會利用到電腦。不過依家已經發展咗好多專業去研究電腦嘅建立、調整同運用。經過幾十年發展,電腦專業已經拓展為幾個新學科,主要嘅分類如下:

  • 電腦工程喺電子工程其中一個分支,以留意硬件、軟件及兩者嘅交流為主。
  • 電腦科學喺一個學術科去理解同電腦有關嘅程序,例如發展不同方法去處理特定工作。呢科仲處理關於利用電腦去解決問題、如何有效率去用電腦解決問題同有效率嘅程式去計出答案嘅問題。好多電腦科學專才利用這學科去解決不同方面嘅問題。
  • 軟件工程研究方法去使軟件變得更快、更穩定、用更少步驟去處理工作。
  • 資訊系統專注電腦喺團體(尤其喺商業裏面)嘅發展同運用。
  • 好多範疇嘅專業都會利用到電腦;就例如一個地理資訊專家應用電腦去管理地理資訊。

依家有兩個主要專業電腦學會,分別係美國電腦協會(the Association for Computing Machinery)同IEEE 電腦協會(IEEE Computer Society)。

Wikimedia Commons有媒體同下面嘅題目有關: