Hardware & Software
IGCSE Computer Science Topic 4 13:08 English narration · English + 中文 subtitles burned in
Chapters
Transcript
Here is a brand new computer.
这里有一台全新的电脑。
Every physical part works — the processor, the memory, the screen, the keyboard.
每一个物理部件都是好的——处理器、内存、屏幕、键盘。
Switch it on, and nothing happens.
打开电源,却什么也没发生。
No desktop, no cursor, nothing at all.
没有桌面,没有光标,什么都没有。
Because hardware on its own cannot do anything useful.
因为硬件光靠自己,做不成任何有用的事。
It needs instructions.
它需要指令。
Software is those instructions — and between the bare metal and the app you actually use, there are several layers, each one running on the layer below it.
软件就是这些指令——而在裸露的机器和你真正在用的应用之间, 还有好几个层次,每一层都跑在它下面那一层之上。
Today we take that stack apart.
今天我们就把这一整摞拆开来看。
Hardware, software, and the layers between them.
硬件、软件,以及它们之间的那些层。
Today: hardware versus software, system and application software, the layer stack, what the operating system does, interrupts, high-level and low-level languages, compilers, interpreters and assemblers, and the IDE.
今天我们讲:硬件与软件的区别、系统软件与应用软件、 层次结构、操作系统都做些什么、中断、高级语言与低级语言、编译器、解释器和汇编器, 以及集成开发环境。
Let's begin.
让我们开始吧。
Start with the split.
先从这个区分说起。
Hardware is the physical parts — the parts you can actually touch.
硬件是物理的部件——你真的可以摸到的那些东西。
The processor — the central processing unit — the memory, the keyboard, the screen, the hard disk.
处理器、内存、键盘、屏幕、硬盘。
Software is the programs: the instructions that control the computer and tell the hardware what to do.
软件则是程序:那些控制计算机、告诉硬件该做什么的指令。
And here is the key sentence for the exam.
而下面这句话,是考试的关键句。
Hardware cannot do anything useful on its own, and software needs hardware to run on.
硬件光靠自己做不成任何有用的事,而软件也需要硬件才能运行。
You need both.
两者缺一不可。
This is hardware — the physical parts you can pick up and hold.
这就是硬件——你可以拿起来、握在手里的实体部件。
A motherboard, the chips on it, the cables.
一块主板、上面的芯片、还有线缆。
Software is the opposite: the programs and instructions that tell that hardware what to do.
软件正相反: 它是告诉硬件该做什么的程序和指令。
You cannot touch software.
软件是摸不到的。
A useful way to test yourself in an exam: if you could drop it on your foot, it is hardware.
考试时可以用一个好用的自测方法:如果它能砸到你的脚,那就是硬件。
And neither is any use alone.
而且两者缺一不可。
Hardware with no software is an expensive brick; software with no hardware has nothing to run on.
只有硬件没有软件,就是一块昂贵的砖头; 只有软件没有硬件,它就没有地方可以运行。
Software splits into two families and the exam wants you to sort examples correctly.
软件分成两大类,而考试要求你能把例子正确归类。
System software runs and manages the computer itself: the operating system, compilers and linkers, device drivers that let the OS control a piece of hardware, and utility software like anti-virus, backup and disk clean-up.
系统软件运行和管理计算机本身:操作系统、编译器和链接器、 让操作系统能够控制某个硬件的设备驱动程序, 以及杀毒、备份、磁盘清理这类实用程序。
Application software lets the USER do a useful task: word processing, spreadsheets, a database management system, a web browser.
应用软件让用户完成有用的任务:文字处理、电子表格、 数据库管理系统、网页浏览器。
The test is who it serves.
判断标准是它服务于谁。
If it serves the computer, in the background, it is system software.
如果它在后台服务于计算机,那就是系统软件。
If it serves the person sitting at the keyboard, it is application software.
如果它服务于坐在键盘前的那个人,那就是应用软件。
Software splits into two types.
软件分成两类。
System software controls the computer itself and gives other programs a base to run on — the operating system, device drivers that let the operating system control a piece of hardware, utility software like anti-virus and backup tools, and the compilers and linkers that turn programs into a runnable form.
系统软件控制计算机本身,并为其他程序提供一个运行的基础—— 操作系统、让操作系统能控制某个硬件的设备驱动程序、像杀毒和备份这样的实用程序, 还有把程序变成可运行形式的编译器和链接器。
Application software lets the user do a useful task — word processing, spreadsheets, a database management system, a web browser.
应用软件则让用户完成一件有用的事—— 文字处理、电子表格、数据库管理系统、网页浏览器。
The clean way to tell them apart: system software serves the computer, in the background; application software serves the user, directly.
区分它们最干净的办法是: 系统软件在后台服务于计算机;应用软件则直接服务于用户。
Now stack them up.
现在把它们摞起来。
At the bottom, hardware — the physical machine.
最底下是硬件——那台物理的机器。
Just above it, firmware: software stored permanently on ROM or flash, which runs the moment you switch the power on.
紧挨着它上面是固件: 永久存放在 ROM 或闪存里的软件,一通电它就开始运行。
The BIOS and the bootloader are firmware — they test the hardware, then load the operating system.
BIOS 和引导程序都属于固件—— 它们先检测硬件,然后把操作系统加载起来。
Above that sits the operating system itself.
再往上就是操作系统本身。
And on top of that, the application software, and finally you, the user.
而在操作系统之上,是应用软件,最上面才是你,也就是用户。
Each layer runs on the layer below it.
每一层都跑在它下面那一层之上。
That is why the machine seemed dead a moment ago: with no software, the stack has only its bottom step.
这也正是刚才那台机器像是坏了的原因:没有软件,这一摞就只剩最底下那一级。
Read the stack from the bottom up, because each layer runs on the one below it.
从下往上读这个层次结构,因为每一层都运行在它下面那一层之上。
Hardware at the base.
最底下是硬件。
Then firmware — software stored permanently on ROM or flash that runs the MOMENT the computer is switched on.
然后是固件——永久存放在 ROM 或闪存里的软件, 在计算机通电的那一刻就开始运行。
The BIOS and the bootloader are firmware: they test the hardware and then load the operating system.
BIOS 和引导程序都是固件:它们先检测硬件,然后加载操作系统。
Above that sits the operating system, and above that the application software the user actually opens.
再上面是操作系统,最上面是用户真正打开的应用软件。
That is the order to write down: hardware, firmware, operating system, application software.
要写下来的顺序就是:硬件、固件、操作系统、应用软件。
Firmware is the layer students forget, and it is the one that explains how anything starts at all.
固件是学生最容易忘掉的一层,而它恰恰解释了一切究竟是怎么启动起来的。
So what does the operating system actually do?
那么操作系统究竟在做什么呢?
Eight roles, and the exam can ask for any of them.
有八项职责,考试可能问到其中任何一项。
It manages files — saving, opening, naming, moving and deleting them.
它管理文件——保存、打开、命名、移动和删除。
It handles interrupts.
它处理中断。
It provides a user interface so you can control the machine.
它提供用户界面,让你能操作这台机器。
It manages memory, deciding what stays in RAM and where.
它管理内存,决定什么留在 RAM 里、放在哪儿。
It manages peripherals and their drivers, like printers.
它管理外围设备和它们的驱动程序,比如打印机。
It manages multitasking, letting several programs run at once.
它管理多任务处理,让好几个程序同时运行。
It provides a platform for application software to run on.
它为应用软件提供一个运行的平台。
And it manages security — user accounts, passwords and access rights.
而且它还管理安全——用户账户、密码和访问权限。
Without an operating system, a computer is very hard to use.
没有操作系统,一台计算机会非常难用。
One of those roles deserves its own look: handling interrupts.
这些职责里,有一项值得单独看看:处理中断。
An interrupt is a signal sent to the processor, saying that something needs attention right now.
中断是发送给处理器的一个信号, 告诉它有件事现在就需要处理。
It can come from three places.
它可能来自三个地方。
From hardware — a key is pressed, or a printer runs out of paper.
来自硬件——比如有人按了一个键, 或者打印机没纸了。
From software — a program tries to divide by zero.
来自软件——比如某个程序试图除以零。
Or from the user — somebody presses cancel.
或者来自用户——比如有人按了取消。
And here is what the processor does, in order.
而处理器接下来会按顺序做这几件事。
It stops what it is doing.
它停下手上正在做的事。
It saves its place.
它保存自己的位置。
It services the interrupt — runs the routine that deals with it.
它服务这个中断——也就是运行处理它的那段例程。
Then it restores its place, and carries on exactly where it left off.
然后它恢复原来的位置, 从刚才停下的地方继续往下做。
That save-and-restore is what lets a computer react instantly without losing its work.
正是这个"保存再恢复",让计算机能够立刻响应,却不会丢掉手上的工作。
Programs are written in a programming language, and there are two kinds.
程序是用编程语言写出来的,而编程语言有两类。
A high-level language is written in words that look a bit like English — Python, for example.
高级语言用的词看上去有点像英语——比如 Python。
It is easy for people to read, write and fix, and it is independent of the computer, so the same program can run on different types of machine.
它对人来说容易读、容易写、也容易改,而且它独立于具体的计算机, 所以同一个程序可以在不同类型的机器上运行。
A low-level language is close to what the hardware actually uses.
低级语言则贴近硬件真正使用的东西。
That means machine code — instructions in binary, which the processor runs directly — and assembly language, which is machine code written with short word codes, called mnemonics, instead of binary.
它包括机器码——用二进制写的指令,处理器可以直接执行——以及汇编语言, 也就是把机器码写成简短的助记符,而不是二进制。
A low-level language is tied to one specific type of processor, so a program written for one may not run on another.
低级语言和某一种特定型号的处理器绑在一起, 所以为一种处理器写的程序,在另一种上可能跑不了。
You use it when you need full control of the hardware, or very fast, very small code.
当你需要完全掌控硬件,或者需要非常快、非常小的代码时,才会用它。
Three layers again.
又是三层结构。
At the top, a high-level language: close to human language, and it will run on any computer.
最上面是高级语言:接近人类语言,而且它可以在任何计算机上运行。
Below it, assembly language: machine code written with short word codes, mnemonics like L D A and A D D, instead of binary.
下面一层是汇编语言:用简短的助记符来书写的机器码, 比如 L D A 和 A D D,而不是二进制。
At the bottom, machine code itself — pure binary, which the CPU runs directly.
最底下是机器码本身——纯二进制,CPU 直接执行它。
The key exam point is about the bottom two.
考试的关键点在下面这两层。
A low-level language relates to one SPECIFIC type of CPU, so a program written for one processor may simply not run on another.
低级语言对应的是某一种特定型号的 CPU, 所以为一种处理器写的程序,在另一种上可能根本无法运行。
You use it when you need full control of the hardware, or very fast, very small code.
你在需要完全掌控硬件、或者需要极快极小的代码时才会用它。
A team is writing a program.
一个团队正在开发一个程序。
While developing it they want to find and fix errors quickly; when they ship it they want customers to run it fast without seeing the source code.
开发过程中他们希望快速找到并修正错误; 发布时他们希望客户运行得快,而且看不到源代码。
Which translator suits each stage?
每个阶段各适合哪种翻译程序?
While developing, use an interpreter: it translates and runs one line at a time and stops at the first error, so a mistake is easy to locate.
开发阶段用解释器:它一次翻译并运行一行,遇到第一个错误就停下来, 所以错误很容易定位。
To ship, use a compiler: it translates the whole program once into machine code, which then runs quickly with no translator present, and the customer receives only the executable rather than the source.
发布时用编译器:它把整个程序一次性翻译成机器码, 之后运行得很快,也不需要翻译程序在场, 而客户拿到的只是可执行文件,不是源代码。
The two are not rivals.
这两者不是对手。
Name the STAGE and give the reason, because "a compiler is faster" on its own earns nothing.
要说出阶段并给出理由, 因为光说"编译器更快"是拿不到分的。
But the processor can only run machine code, so a high-level program has to be translated first.
但处理器只能运行机器码,所以高级语言写的程序必须先被翻译。
The software that does that is called a translator, and there are two of them for high-level code.
做这件事的软件叫翻译程序, 针对高级代码的有两种。
A compiler translates the whole program into machine code before it is run.
编译器在程序运行之前,把整个程序一次性翻译成机器码。
Translation happens once, in full; all the errors are reported together at the end; and the finished program runs fast and does not need the compiler present in order to run.
翻译只发生一次、而且是整体的;所有错误会在最后一起报出来; 翻译好的程序运行得快,而且运行时不需要编译器在场。
An interpreter translates and runs the program one line at a time.
解释器则是一次一行地边翻译边运行。
It stops at the very first error it finds, which is a real help while you are testing; the program runs more slowly, because it is translated again every time; and the interpreter has to be there every single time the program runs.
它一遇到第一个错误就停下来,这在你调试的时候非常有帮助; 程序运行得更慢,因为每次运行都要重新翻译一遍;而且每一次运行程序,解释器都必须在场。
There is a third translator, for low-level code: an assembler.
还有第三种翻译程序,是给低级代码用的:汇编器。
It turns an assembly-language program — written in mnemonics like LDA and ADD — into machine code.
它把用助记符(比如 LDA 和 ADD)写成的 汇编语言程序,翻译成机器码。
And the special thing about it is that each mnemonic becomes exactly one machine instruction.
它的特别之处在于:每一个助记符正好对应一条机器指令。
A direct, one-to-one translation, unlike a compiler or an interpreter, which work on high-level code.
这是一种直接的、一对一的翻译,和处理高级代码的编译器或解释器都不一样。
Now the question the exam actually asks.
现在来看考试真正会问的那个问题。
A team is writing a program.
一个团队正在写一个程序。
While they develop it, they want to find and fix errors fast — so they use an interpreter, which stops at the first error.
在开发阶段, 他们希望能快速找到并修好错误——所以他们用解释器,因为它一遇到第一个错误就停。
When they ship it, they want customers to run it quickly without seeing the source — so they use a compiler.
而在发布的时候,他们希望客户能快速运行、而且看不到源代码——所以他们用编译器。
The two are not rivals.
这两者并不是对手。
Name the stage, and give the reason.
要说清楚是哪个阶段,并给出理由。
Just saying a compiler is faster earns you nothing.
光说一句"编译器更快",是一分都拿不到的。
Here they are together.
现在把它们放在一起看。
The compiler translates the whole program ONCE into machine code, and that machine code then runs many times without translating again.
编译器把整个程序一次性翻译成机器码, 之后这段机器码可以反复运行,不必再翻译。
The interpreter translates and runs one line at a time, every time the program runs.
解释器则一次翻译并运行一行,而且每次运行程序都要重来一遍。
Four differences to remember: what they translate, whole program against one line; how errors appear, all at the end against stopping at the first; the speed of the finished program, faster against slower; and whether the translator is still needed to run it later — no for a compiler, yes for an interpreter.
要记住四个区别:翻译什么,是整个程序还是一行; 错误怎么出现,是最后一起报出还是遇到第一个就停; 成品程序的速度,是更快还是更慢; 以及以后运行时还需不需要翻译程序——编译器不需要,解释器需要。
That last row is the one most often missed.
最后这一行是最常被漏掉的。
The third translator is the assembler, and it belongs in a different box from the other two.
第三种翻译程序是汇编器,它和另外两种不属于同一类。
It takes assembly language — a LOW-level program written in mnemonics like L D A and A D D — and turns it into machine code.
它接受的是汇编语言——用 L D A、A D D 这类助记符写成的低级程序—— 并把它变成机器码。
And the translation is one-to-one: each mnemonic becomes exactly one machine instruction.
而且这种翻译是一一对应的:每一个助记符恰好变成一条机器指令。
That is unlike a compiler or an interpreter, which both work on HIGH-level code, where a single line can expand into many machine instructions.
这和编译器、解释器都不同,那两者处理的是高级代码, 其中一行可以展开成很多条机器指令。
So when a question asks you to distinguish the three translators, the assembler is separated by what it takes IN, not just by how it works.
所以当题目要求区分这三种翻译程序时, 汇编器的区别在于它的输入是什么,而不只是它怎么工作。
An integrated development environment puts every tool a programmer needs in one place, and the exam expects you to list them.
集成开发环境把程序员需要的每一样工具都放在一个地方, 而考试要求你能把它们列出来。
A code editor for typing the program.
代码编辑器,用来输入程序。
A run time environment for running it to test it.
运行时环境,用来运行程序进行测试。
A translator — a compiler or an interpreter — to turn the code into machine code.
翻译程序——编译器或解释器——用来把代码变成机器码。
Error diagnostics: messages that help you find and understand mistakes.
错误诊断:帮助你找到并理解错误的提示信息。
Auto-completion and auto-correction, which finish or fix code as you type.
自动补全和自动纠错,会在你输入时补完或修正代码。
And prettyprinting, which lays the code out neatly with colour and indentation so it is easy to read.
还有美化打印,用颜色和缩进把代码排得整整齐齐,便于阅读。
Look at the screen: the colouring you can see IS prettyprinting.
看这个屏幕:你看到的这些配色就是美化打印。
Last, the tool you write it all in: an integrated development environment, or IDE.
最后是你用来写这一切的那个工具:集成开发环境,简称 IDE。
It gathers the useful tools into one place.
它把有用的工具都集中到一个地方。
A code editor for typing your program.
代码编辑器,用来输入你的程序。
A run time environment, for running it to test it.
运行时环境,用来运行程序做测试。
A translator — a compiler or an interpreter.
翻译程序——编译器或者解释器。
Error diagnostics: messages that help you find and understand your mistakes.
错误诊断:帮你找到并理解自己错在哪里的提示信息。
Auto-completion and auto-correction, which finish or fix code as you type.
自动补全和自动纠错, 在你打字的同时帮你补完或改正代码。
And prettyprinting, which lays the code out neatly, with colour and indentation, so it is easy to read.
还有美化打印,把代码用颜色和缩进整整齐齐地排好, 让它读起来轻松。
Four marks to lock in.
四个要拿稳的分。
First, system software runs the computer, while application software does a task for the user.
第一,系统软件负责运行这台计算机,而应用软件替用户完成某项任务。
Second, a compiler translates the whole program at once and the result runs fast; an interpreter goes line by line and stops at the first error.
第二,编译器把整个程序一次性翻译完,翻译出来的程序运行得快; 解释器一行一行地来,遇到第一个错误就停。
Third, high-level languages run on any computer, while low-level languages are tied to one type of processor.
第三,高级语言在任何计算机上都能运行, 而低级语言绑定在某一种处理器上。
Fourth, an interrupt makes the processor stop, save its place, service the event, then carry on.
第四,中断会让处理器停下、保存位置、 服务这个事件,然后再继续。
Nail these, and this topic is yours.
掌握这些,这个专题就是你的了。