2.5 - Languages & Translators Flashcards
What is a high-level programming language?
- Uses syntax similar to a natural human language to make it easier to understand and use
- Must be translated into machine code before it can be run
What are the pros/cons of high-level languages?
- More easily written and understood by humans
- Portable (can be run on many different CPUs)
- Slow to run
What is a low-level language?
Does not closely resemble a natural human language making it harder for humans to understand and use
State the pros/cons of low-level languages
-Low-level languages are easier to optimise
-Low-level languages allow the user to directly manipulate memory
-Low-level languages are specific to particular CPUs
What are the two types of low-level language?
- Machine Code
- Assembly Language
What is machine code?
Binary
What is assembly language?
Uses specialised command mnemonics to perform actions
Why do computers use binary?
Computers are made up of millions of transistors (switches) which can only represent two states (ON and OFF)
What are the two types of translator?
- Interpreter
- Compiler
What are 2 differences between compilers and interpreters?
Execution method:
- Interpreters translates the source code into machine code line-by-line
- Compilers translate all the source code into machine code in one go and produce an executable file
Execution speed:
- Interpreters are slower than compilers because the code must be reinterpreted each time the program is run
- Compilers can produce much more efficient code than interpreters, making the compiled programs run faster
Complexity:
- Interpreters are smaller, simpler programs
- Compilers are large, complex programs
Error reporting:
- Interpreters report errors to the user immediately and stops translation
- Compilers produces all the errors in an error file at the end of compilation
Repetition:
- Interpreters must reinterpret the program every time
- Compilers doesn’t need reinterpretation, but must be re-compiled after changes are made
What are the benefits of using a compiler?
- Produces an executable program: No need to repeat this process more than once per version of the software
- Hides the source code from the end user: Protects developers’ intellectual property
- Source code not needed afterwards
- Fast to execute afterwards
What are the drawbacks of using a compiler?
-Very slow compilation process: This can slow down development if many small changes need to be made
- Errors only shown right at the end
What are the benefits of using an interpreter?
-Interpreted languages are ‘portable’: This means that they can be run on many different types of CPU as long as there is an interpreter available for the platform
- Errors discovered straight away
- Good for small changes
What are the disadvantages of using an interpreter?
- Source code needed to run
- Slower to execute
What is the purpose of the IDE (Integrated Development Environment)?
Provides programmers with tools to help create programs
What are some of the functions of the IDE?
- Editor
- Error diagnostics and debugger
- Run time environment
- Translator
- Break point
- Variable watch/watch window
- Trace
What does the editor do?
Allows a programmer to enter and edit source code - Features may include:
- Automatic formatting
- Automatic line numbering
- Automatic colour coding
- Statement completion.
What does a break point do?
Allows the programmer to select a specific line and the program displays variable values at that point - a process called single-stepping
What does a variable watch / watch window do?
Displays the current value of a selected variable which can be watched line-by-line to see how the value changes
What does trace do?
Logs the values of variables and outputs of the program as the code is executed line by line
What do the error diagnostics and debugger do?
- Displays information about an error when it occurs (when the program fails to compile or run), such as the line it occurred on and the error type
- The debugger helps locate, identify and rectify errors in a program
- May also suggest solutions to help the programmer find and fix the error
What does a runtime environment do?
Allows user to run and test the program to determine if there are any logic errors