GCSE Computer Science · 2.5
Programming Languages and IDEs
Name
Class
Date
Mark / 29
Section A
Circle the letter of the correct answer. One mark each.
- 1Which is a characteristic of a high level language?1
- AIt is specific to one type of processor
- BIt is close to human language and must be translated before running
- CIt runs directly on the processor with no translation
- DIt uses only binary digits
- 2What does a compiler do?1
- AConverts machine code back into source code
- BRuns the program without translating it
- CTranslates and executes one line at a time
- DTranslates the whole program into machine code before it is run
- 3Which is an advantage of an interpreter during program development?1
- AIt only needs to translate the program once
- BIt hides the source code from the user
- CIt stops at the first error, making it easier to locate and fix
- DIt produces an executable file that runs faster
- 4Why is assembly language not portable?1
- AIt is too long to copy between machines
- BIt requires an interpreter that only runs on one operating system
- CIt cannot be saved to a file
- DIt is written for one specific processor instruction set
- 5Which IDE feature pauses a program at a chosen line so variables can be inspected?1
- AA breakpoint
- BThe editor
- CAuto complete
- DSyntax highlighting
- 6What does an assembler translate?1
- APython into Java
- BHigh level code into machine code
- CAssembly language into machine code
- DMachine code into assembly language
- 7What is the main benefit of syntax highlighting?1
- AKeywords, strings and comments are coloured differently so errors stand out
- BIt automatically fixes logic errors
- CIt compiles the code
- DThe program runs faster
- 8Why might a developer choose a low level language for an embedded system?1
- AIt runs on any processor without change
- BIt does not need to be translated
- CIt is much easier to write than a high level language
- DIt gives precise control over hardware and can be highly optimised for limited memory
- 9Which statement about a compiled program is correct?1
- AIt is translated every time it runs
- BThe source code is not needed to run the executable
- CIt stops at the first error while running
- DThe source code must be distributed with it
- 10Which of these is NOT typically a feature of an IDE?1
- AError diagnostics
- BA word processor for writing documentation
- CAn editor with syntax highlighting
- DA run time environment
Section B
Answer in the space provided. The number of marks tells you how many separate points to make.
- 1StateState two differences between a compiler and an interpreter.2
- 2ExplainExplain one advantage of using an interpreter and one advantage of using a compiler.4
- 3ExplainExplain why a program written in a high level language must be translated before it can be executed.3
- 4DescribeDescribe three features of an integrated development environment and explain how each helps a programmer.6
- 5ExplainA company is writing software to control a medical device with very limited memory and strict timing requirements. Explain why they might write part of the software in a low level language.4
Mark scheme
Section A
Section B
1 State two differences between a compiler and an interpreter. 2
One mark for each of the following, to a maximum of 2.
- A compiler translates the whole program at once, an interpreter translates line by line
- A compiler reports all errors at the end, an interpreter stops at the first error
Model answer. A compiler translates the entire program into machine code in one operation before it is run, whereas an interpreter translates and executes the program one line at a time each time it is run. In addition, a compiler reports all the errors it has found together once translation is complete, while an interpreter stops as soon as it reaches the first error and reports that one immediately.
2 Explain one advantage of using an interpreter and one advantage of using a compiler. 4
One mark for each of the following, to a maximum of 4.
- Interpreter advantage: errors are reported one at a time as they are reached
- Which makes it easier to locate and correct errors during development
- Compiler advantage: the resulting executable runs faster as no translation happens at run time
- Or: the source code does not need to be given to the user, protecting it
Model answer. An advantage of an interpreter is that it stops at the first error it encounters and reports it immediately, along with the line it occurred on. This makes it much easier to develop and debug a program, because the programmer deals with one problem at a time in the context of where it happened, rather than being presented with a long list of errors after attempting to translate the whole program. An advantage of a compiler is that the program is fully translated into machine code before it is distributed, so when it is run there is no translation overhead and the resulting executable runs considerably faster. A further advantage is that only the executable needs to be given to the user, so the developer's source code remains private.
3 Explain why a program written in a high level language must be translated before it can be executed. 3
One mark for each of the following, to a maximum of 3.
- A processor can only execute machine code
- High level languages use English-like statements the processor cannot execute directly
- A translator such as a compiler or interpreter converts it into machine code
Model answer. A processor is built to execute only machine code, which consists of binary instructions drawn from its own instruction set. A high level language uses English-like keywords and statements such as if, while and print, which are designed to be readable by people rather than by hardware, and the processor has no way of acting on them directly. A translator, either a compiler or an interpreter, is therefore required to convert the high level source code into the machine code instructions that the processor can actually execute.
4 Describe three features of an integrated development environment and explain how each helps a programmer. 6
One mark for each of the following, to a maximum of 6.
- An editor for writing code
- With features such as syntax highlighting and auto indentation that make errors visible
- Error diagnostics that identify problems
- Giving the line number and type of error so it can be located quickly
- A run time environment allowing the program to be run and tested inside the IDE
- Debugging tools such as breakpoints and variable watches
Model answer. The first feature is the editor, which is where the code is written. It provides syntax highlighting, colouring keywords, strings and comments differently so that the structure of the code is immediately visible and a misspelled keyword or an unclosed quotation mark stands out, along with automatic indentation, bracket matching and line numbers that correspond to those quoted in error messages. The second feature is error diagnostics, which identifies problems in the code and reports the line number and the type of error, often highlighting the offending code as it is typed. This lets the programmer locate and fix errors far more quickly than searching manually. The third feature is the run time environment together with debugging tools, which allows the program to be executed and tested from within the IDE without leaving it or invoking a translator manually. Debugging tools such as breakpoints, which pause execution at a chosen line, and variable watches, which show values changing as the program runs, allow the programmer to inspect exactly what the program is doing at the moment a fault occurs, which is the only reliable way to find logic errors.
5 A company is writing software to control a medical device with very limited memory and strict timing requirements. Explain why they might write part of the software in a low level language. 4
One mark for each of the following, to a maximum of 4.
- Low level languages give direct control over the hardware
- Code can be optimised to use very little memory
- Execution can be made faster and timing more predictable
- Acknowledges the drawback that it is harder to write and not portable
Model answer. A low level language such as assembly gives the programmer direct control over the processor's registers and memory locations, which is exactly what is needed when a device has very limited memory. The programmer can decide precisely how every byte is used rather than relying on a compiler to make general purpose decisions, so the code can be made far more compact than the equivalent high level program. Timing is the other reason: each assembly instruction corresponds closely to one machine code instruction, so the programmer knows exactly how long a section of code takes to execute, which matters enormously in a medical device that must respond within a guaranteed time. The drawbacks are significant, since low level code is much harder to write, read and debug, and it is specific to one processor so it cannot be reused if the hardware changes. For that reason the company would most likely write the bulk of the software in a high level language and use low level code only for the small, timing critical sections where it is genuinely needed.