📚 Programming Languages: Paradigms and Translation | 编程语言:范式与翻译
Programming languages are the bridge between human problem solving and machine execution. In Edexcel A Level Computer Science, candidates must compare language types, explain common paradigms, and describe how source code is translated into executable form. This revision guide covers low-level and high-level languages, the main programming paradigms, translation tools, and debugging techniques.
编程语言是人类问题求解与机器执行之间的桥梁。在 Edexcel A Level 计算机科学中,考生需要比较语言类型、解释常见编程范式,并描述源代码如何被翻译为可执行形式。本复习指南涵盖低级语言与高级语言、主要编程范式、翻译工具和调试技术。
1. Low-Level and High-Level Languages | 低级语言与高级语言
Low-level languages are close to hardware and give direct control over memory and processor registers. High-level languages are closer to human language and use abstraction, making programs easier to read, write and maintain.
低级语言接近硬件,可直接控制内存和处理器寄存器。高级语言更接近人类语言并使用抽象,使程序更易读、易写、易维护。
Low-level languages offer fast execution and precise control, which is useful for embedded systems and device drivers. However, they are difficult to debug and not portable across different processor families. High-level languages improve productivity and portability, but their source code must be translated before it can run.
低级语言执行速度快、控制精确,适用于嵌入式系统和设备驱动程序。然而它们难以调试,并且不能在多种处理器系列之间移植。高级语言提高了开发效率和可移植性,但其源代码必须经过翻译后才能运行。
- Low-level languages: machine code and assembly are processor-specific and require detailed hardware knowledge.
- 低级语言:机器码和汇编语言面向特定处理器,需要详细的硬件知识。
- High-level languages: Python, Java, C# and Visual Basic allow portable source code across platforms with suitable translators.
- 高级语言:Python、Java、C# 和 Visual Basic 可在合适的翻译器支持下跨平台移植源代码。
2. Machine Code and Assembly Language | 机器码与汇编语言
Machine code consists of binary instructions that a CPU can execute directly. Each instruction has an opcode and often an operand, stored as patterns such as 10110000 01100001. Assembly language uses mnemonics such as LDA, ADD, STA and machine-specific operands, which an assembler converts into machine code.
机器码由 CPU 可直接执行的二进制指令组成。每条指令包含操作码和通常的操作数,以 10110000 01100001 等模式存储。汇编语言使用 LDA、ADD、STA 等助记符和机器特定的操作数,汇编器将其转换为机器码。
One assembly instruction usually maps to one machine instruction, giving fast execution but long development time. Programs written for one architecture, such as x86, will not run directly on another, such as ARM.
一条汇编指令通常对应一条机器指令,因此执行速度快,但开发时间长。为某一架构(如 x86)编写的程序无法直接在另一架构(如 ARM)上运行。
- Machine code uses binary opcodes and operands understood directly by the control unit.
- 机器码使用二进制操作码和操作数,由控制单元直接理解。
- Assembly language improves readability through mnemonics but still requires knowledge of registers and memory addressing.
- 汇编语言通过助记符提高了可读性,但仍需了解寄存器和内存寻址知识。
3. Imperative and Procedural Paradigms | 命令式与过程式范式
The imperative paradigm focuses on describing how a task is completed using sequences, selection and iteration. Procedural programming builds on this by organising code into procedures, functions or subroutines that can be called with parameters and return values.
命令式范式侧重于通过顺序、选择和迭代描述任务如何完成。过程式编程在此基础上将代码组织为过程、函数或子程序,可通过参数调用并返回值。
Procedural languages encourage modularity, reuse and stepwise refinement. Local and global variables must be managed carefully to avoid unintended side effects. Breaking a large problem into smaller procedures also makes testing and maintenance easier.
过程式语言鼓励模块化、代码复用和逐步求精。必须谨慎管理局部变量和全局变量,以避免意外的副作用。将大型问题拆分为较小的过程也使得测试和维护更加容易。
subtotal = quantity × price → total = subtotal + tax → output total
示例:先计算小计,再计算含税总额,最后输出结果。
4. Object-Oriented Programming | 面向对象编程
Object-oriented programming (OOP) models real-world or abstract entities as classes and objects. A class defines attributes and methods; objects are instances created from a class. Key principles include encapsulation, inheritance, polymorphism and abstraction.
面向对象编程将现实世界或抽象实体建模为类和对象。类定义属性和方法,对象是由类创建的实例。关键原则包括封装、继承、多态和抽象。
Encapsulation means data and methods are bundled together, and access is controlled through interfaces. Inheritance allows a subclass to reuse and extend the behaviour of a parent class. Polymorphism means the same method name can behave differently depending on the object type.
封装意味着数据和方法捆绑在一起,通过接口控制访问。继承允许子类复用并扩展父类的行为。多态意味着同一方法名可根据对象类型表现出不同行为
Published by TutorHao | A-Level 编程 Revision Series | aleveler.com
更多咨询请联系16621398022(同微信)
屏轩国际教育cambridge primary/secondary checkpoint, cat4, ukiset,ukcat,igcse,alevel,PAT,STEP,MAT, ibdp,ap,ssat,sat,sat2课程辅导,国外大学本科硕士研究生博士课程论文辅导