Back to 课程

Computer Science GCES AQA

0% Complete
0/0 Steps
  1. Representing Algorithms Aqa
    4 主题
  2. Efficiency Of Algorithms Aqa
    1 主题
  3. Searching Algorithms Aqa
    3 主题
  4. Sorting Algorithms Aqa
    3 主题
  5. Data Types Aqa
    1 主题
  6. Programming Concepts Aqa
    5 主题
  7. Arithmetic Relational And Boolean Operations Aqa
    1 主题
  8. Data Structures Aqa
    3 主题
  9. String Manipulation Aqa
    1 主题
  10. Random Number Generation Aqa
    1 主题
  11. Structured Programming Aqa
    2 主题
  12. Robust And Secure Programming Aqa
    4 主题
  13. Number Bases Aqa
    2 主题
  14. Converting Between Number Bases Aqa
    3 主题
  15. Units Of Information Aqa
    9 主题
  16. Hardware And Software Aqa
    4 主题
  17. Boolean Logic Aqa
    3 主题
  18. Programming Languages And Translators Aqa
    2 主题
  19. Cpu Architecture Performance And Embedded Systems Aqa
    4 主题
  20. Memory Aqa
    2 主题
  21. Secondary Storage Aqa
    3 主题
  22. Fundamentals Of Computer Networks Aqa
    8 主题
  23. Fundamentals Of Cyber Security Aqa
    1 主题
  24. Methods Of Preventing Cyber Security Threats Aqa
    1 主题
  25. Relational Databases Aqa
    2 主题
  26. Ethical Legal And Environmental Impacts Aqa
    2 主题
课 Progress
0% Complete

Exam code:8525

Translators

What is a translator?

  • A translator is a program that translates program source code into machine code so that it can executed directly by a processor

  • Low-level languages such as assembly code are translated using an assembler

  • High-level languages such as Python are translated using a compiler or interpreter

What is an assembler?

  • An assembler translates mnemonics written in assembly language (low-level) in to machine code

  • Each lime of assembly language is assembled into a single machine code instruction

  • Assemblers have been used less and less since high-level languages were introduced

Advantages

Disadvantages

Speed of execution

Difficult to write due to limited and hard to understand commands

Optimises the code

Changes mean it must be reassembled

Original source code will not be seen

Designed solely for one specific processor

What is a compiler?

  • A compiler translates high-level languages into machine code all in one go

  • Compilers translate inputs into machine code directly

  • Compilers are generally used when a program is finished and has been checked for syntax errors

  • Compiled code can be distributed (creates an executable) and run without the need for translation software

  • If compiled code contains any errors, after fixing, it will need re-compiling

Advantages

Disadvantages

Speed of execution

Can be memory intensive

Optimises the code

Difficult to debug

Original source code will not be seen

Changes mean it must be recompiled

 

It is designed solely for one specific processor

What is an interpreter?

  • An interpreter translates high-level languages into machine code one line at a time

  • Each line is executed after translation and if any errors are found, the process stops

  • Interpreters do not generate machine code directly, appropriate machine code subroutines are called

  • Interpreters are generally used when a program is being written in the development stage

  • Interpreted code is more difficult to distribute as translation software is needed for it to run

Advantages

Disadvantages

Stops when it finds a specific syntax error in the code

Slower execution

Easier to debug

Every time the program is run it has to be translated

Require less RAM to process the code

Executed as is, no optimisation

Worked Example

A computer program is written in a high-level programming language.

(a) State why the computer needs to translate the code before it is executed.[1]

(b) Either a compiler or an interpreter can translate the code. Describe two differences between how a compiler and an interpreter would translate the code.[2]

How to answer this question

  • (a) what type of language does a computer understand?

  • (b) the keyword is ‘how’

Answer

(a)

  • To convert it to binary/machine code

  • The processor can only understand machine code

(b)

  • Compiler translates all the code in one go…

  • …whereas an interpreter translates one line at a time

  • Compiler creates an executable…

  • …whereas an interpreter does not/executes one line at a time

  • Compiler reports an error at the end…

  • …whereas an interpreter stops when it finds an error

Responses

您的邮箱地址不会被公开。 必填项已用 * 标注