Interpreter for development, compiler for the final program

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

Interpreter for development, compiler for the final program

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Which translator is usually used while a programmer is still writing and testing the program?
A Interpreter
B Compiler
2. A programmer changes one line and wants to see the result at once. What helps most?
A A compiler, because it must rebuild the whole program before every test
B An interpreter, because there is no wait for the whole program to compile
3. Which translator is normally used to produce the final version of the program for release?
A Compiler
B Interpreter
4. A company wants to give customers a program without sharing its source code. What should it do?
A Give users the source code and an interpreter
B Compile the program and give users the executable file
5. Which statement is true about the final release of a program?
A It is compiled once, then the executable can be run many times
B It must be translated again every time a user runs it

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1Run the program line by line while writing it Acompile game.src -> game.exe
2Compile the finished program once for release Bprint(total) # edit, run, see the result at once
3While developing, an interpreter lets you test a small change straight away with no wait for full compilation CThe final program should be compiled once into an executable. Giving out source code is less secure and the program runs slower when interpreted.
4For release, the program is compiled once and users receive an executable without the source code DUsing a compiler to translate the final program into a fast executable file that users can run
5Developer compiles the whole program again after every small change while testing, and waits each time ERecompiling the full program after every small edit wastes time during development. An interpreter should be used for quick testing and fixing.
6Company sends customers the source code and an interpreter so they can run the final program FUsing an interpreter during development so you can test and fix code quickly without waiting for full compilation

Definitions

interpreter for development, compiler for release

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
developmentTranslator ← ___________
2.
releaseTranslator ← ________
3.
sendToUsers(__________)
4.
compileCountForRelease ← _
5.
_____ bugsExist testWith(interpreter) ENDWHILE

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A phase <- 'developing'
B IF phase = 'development' THEN
C tool <- 'interpreter'
D ENDIF
Question 2
A phase <- 'release'
B IF phase = 'release'
C tool <- 'compiler'
D ENDIF
Question 3
A phase <- 'development'
B tool <- 'compiler'
C OUTPUT 'Test and fix quickly'
Question 4
A phase <- 'release'
B tool <- 'compiler'
C delivered <- 'executable file'
D OUTPUT 'Users: ' + source
Question 5
A REPEAT
B RUN with interpreter
C FIX the error found
D UNTIL errors remain

Answer Key

Interpreter for development, compiler for the final program
Section A: Quick Questions
Q1
A — Interpreter
Q2
B — An interpreter, because there is no wait for the whole program to compile
Q3
A — Compiler
Q4
B — Compile the program and give users the executable file
Q5
A — It is compiled once, then the executable can be run many times
Section B: Match the Pairs
Q1
Run the program line by line while writing it → Using an interpreter during development so you can test and fix code quickly without waiting for full compilation
Q2
Compile the finished program once for release → Using a compiler to translate the final program into a fast executable file that users can run
Q3
While developing, an interpreter lets you test a small change straight away with no wait for full compilation → print(total) # edit, run, see the result at once
Q4
For release, the program is compiled once and users receive an executable without the source code → compile game.src -> game.exe
Q5
Developer compiles the whole program again after every small change while testing, and waits each time → Recompiling the full program after every small edit wastes time during development. An interpreter should be used for quick testing and fixing.
Q6
Company sends customers the source code and an interpreter so they can run the final program → The final program should be compiled once into an executable. Giving out source code is less secure and the program runs slower when interpreted.
Section C: Definitions
Q1
interpreter for development, compiler for release — Use an interpreter while developing to test and fix code quickly, then compile the final program once into a fast executable to give users without the source code.
Section D: Fill in the Blanks
Q1
developmentTranslator ← interpreter
Q2
releaseTranslator ← compiler
Q3
sendToUsers(executable)
Q4
compileCountForRelease ← 1
Q5
WHILE bugsExist testWith(interpreter) ENDWHILE
Section E: Spot the Error
Q1
A — The string 'developing' does not match 'development' in the IF test, so the interpreter branch would never run. Line 1 should be phase <- 'development'.
Q2
B — An IF statement must end with THEN. Line 2 should be IF phase = 'release' THEN.
Q3
B — During development an interpreter is used because it lets you test and fix code quickly. A compiler is for the final release. Line 2 should be tool <- 'interpreter'.
Q4
D — The variable source was never created, so the program fails. The line should use the variable delivered, which holds the executable file given to users.
Q5
D — The test-and-fix cycle should repeat until there are no errors left, not until errors remain. Line 4 should be UNTIL no errors remain.