Study Guide Instructor view
Programming Languages and Translators
Teaching notes for Lesson 3.10, with controls for presenting it.
Keep this page on your own screen. Share only the lesson window. The lesson window holds no teaching notes, so sharing it cannot show them.
Presenting
- Open the lesson in its own window and share that window, not this one.
- Use Next and Previous here, or the lesson’s own, to move through the lesson. Next reveals one thing at a time: the next idea, or the answer to the question on screen, then the next step. Previous takes the last reveal back. The line below says what is on screen and what Next will show.
- Reveal hints and answers when the class is ready, and reset a demonstration before using it again.
The controls need JavaScript and a browser that supports BroadcastChannel. Without them, open the lesson in presentation mode and use its own controls.
The two windows talk to each other only inside this browser, on this device. Nothing is sent to a server, and no account is needed. A second device (a phone or another tablet) cannot follow the lesson window yet.
Now on the lesson window
- On screen
- Next teaching point
Guidance for this point
Lesson plan
- Level
- Intermediate
- Time
- About 90 minutes; the steps below add up to 90
Pupils begin by deciding for themselves whether a game could be written in 0s and 1s, then choose a language level for two contrasting programs, work out what an assembler must do with ADD 5, and compare two ways of translating a French speech before the terms compiler and interpreter are used. They apply the choice to development and release, and meet the IDE as a workflow improvement. The lesson ends with pupils explaining the route from source code to the CPU for both translators, so you can see whether they understand when translation happens and not only the names.
Objectives
- Explain what a high-level language and a low-level language are, and compare them for readability, debugging, machine independence and control of hardware
- Explain that assembly language uses mnemonics and needs an assembler to translate it into machine code
- Describe how a compiler and an interpreter translate a high-level program and how each reports errors
- Compare the advantages and disadvantages of a compiler and an interpreter, and say which suits development and which suits the final program
- Describe the common functions of an integrated development environment (IDE)
Before the lesson
- Write the made-up four-bit machine code on the board: LOAD = 0001, ADD = 0010 (the lesson gives the full table), so that pupils can translate by looking up.
- Mini whiteboards for think questions and show-me answers.
- Prepare two volunteers for a short role-play: one speaks a few sentences in another language (or invented words), and a ‘translator’ translates beside them, then another translates the whole script beforehand.
- Optionally show an IDE and a plain text editor side by side.
- This lesson is 90 minutes: the natural break is after the compare-translators step.
Steps
Introduction Opening
On the lesson window now
On screen: the lesson’s title, module and number; Next adds its objectives and key terms, as the lesson page lists them; Next again begins the first step.
Objectives on screen
- Explain what a high-level language and a low-level language are, and compare them for readability, debugging, machine independence and control of hardware
- Explain that assembly language uses mnemonics and needs an assembler to translate it into machine code
- Describe how a compiler and an interpreter translate a high-level program and how each reports errors
- Compare the advantages and disadvantages of a compiler and an interpreter, and say which suits development and which suits the final program
- Describe the common functions of an integrated development environment (IDE)
Purpose: Pupils begin by deciding for themselves whether a game could be written in 0s and 1s, then choose a language level for two contrasting programs, work out what an assembler must do with ADD 5, and compare two ways of translating a French speech before the terms compiler and interpreter are used. They apply the choice to development and release, and meet the IDE as a workflow improvement. The lesson ends with pupils explaining the route from source code to the CPU for both translators, so you can see whether they understand when translation happens and not only the names.
1. A CPU that knows one language Think 8 min
On the lesson window now
Purpose: Pupils decide for themselves what is hard about writing a game in 0s and 1s, so that high-level languages are asked for before they are described.
Ask
- Would you want the team to write the whole game as 0s and 1s? What would be hard?
- What would you want a programming language to be like instead?
Responses to expect
- Slow to write and nearly impossible to read or correct
- Words and symbols that people can read, where one line can do a lot
Misconceptions to challenge
- A learner may believe: “A CPU can run any language directly if it is fast enough.” Respond: A CPU can only carry out machine code from its own instruction set; anything else must be translated.
- A learner may believe: “Writing in binary would be faster to run so it is always better.” Respond: It might be, but the cost is time and errors for the programmer; the trade-off is the topic of the lesson.
On the board or with the pen
- Draw a person on the left, a CPU on the right, and a question mark between them.
What learners should notice
- Humans want readability; the CPU wants binary; something must connect them.
Checking understanding: Pupils write two difficulties on whiteboards; look for read, write and correct.
Depending on the answers
- If pupils only say ‘it would take long’: ask what would happen to a single missing 0 in thousands of lines.
- If answers are secure: ask what the language might cost in return for being readable.
English as an additional language
- Check language, binary and machine code.
Discussion pause: Thirty seconds of silent thinking, then pairs list two difficulties.
In the lesson window
- Think it through: Would you want the team to write the whole game as 0s and 1s? Say what would be hard about it, and what you would want a programming language to be like instead.
2. When would you choose each? Predict 12 min
On the lesson window now
Purpose: Pupils choose a language level for a phone game and a tiny heart-rate chip, so that high-level and low-level are met as trade-offs, with a driver as a further case.
Ask
- Which kind of language for each program, and why?
- Does low-level mean worse or simpler?
- Which would you choose for a driver for one make of graphics card?
Responses to expect
- High-level for the game (portable, quick to write); low-level for the chip (control and small size)
- No: it means closer to the machine
- Machine code or assembly, because it controls the hardware directly and works on one kind of card
Misconceptions to challenge
- A learner may believe: “A high-level language works on every machine without changes, so it is the right choice for a driver for one card.” Respond: Machine independence is a strength, but the driver is for one make of card. Ask what the team needs to control directly.
- A learner may believe: “A high-level program is always faster for the CPU to carry out.” Respond: It is translated into machine code, so it is not faster in itself.
- A learner may believe: “Low-level means simpler and easier.” Respond: Use the misconception callout: low-level gives control at the cost of being harder to write, read and correct.
On the board or with the pen
- Make a comparison table of high and low against readable, easy to debug, runs on any CPU, controls hardware.
What learners should notice
- Each kind has strengths and weaknesses in readability, debugging, independence and control.
Checking understanding: The level-sort table and driver-language question; ask pupils to give the property that decided each.
Depending on the answers
- If pupils choose high-level for the driver: ask what a driver has to do with the hardware and which kind of language gives that control.
- If answers are secure: ask for a program where high-level is the clear choice and one where low-level is.
Support
- Provide four properties on cards to place in the high or low column.
English as an additional language
- Check readable, portable and control; use the phone and chip pictures.
Discussion pause: Pupils decide on whiteboards before any reasons are discussed.
In the lesson window
- Think it through: Which kind of language would you choose for each program, and why?
- Apply it: A team writes a device driver for one particular make of graphics card, and needs to control the card’s hardware directly. Which choice is best justified?
3. Words for the CPU’s instructions Discover 12 min
On the lesson window now
Purpose: Pupils predict what ADD 5 means and how a program could turn it into bits, so that mnemonics and the assembler are reasoned out.
Ask
- What do you think the assembly instruction ADD 5 asks the CPU to do?
- How could a program turn it into 0s and 1s?
- What is the machine code for LOAD 5 and for ADD 6?
Responses to expect
- Add the contents of address 5 to the accumulator
- Look up the word in a table of instruction codes and write the code followed by the number
- 0001 0101 and 0010 0110
Misconceptions to challenge
- A learner may believe: “An assembler translates a high-level program one line at a time.” Respond: That describes an interpreter. Ask what kind of program an assembler translates.
- A learner may believe: “An assembler runs the machine code on the CPU.” Respond: Running needs no translation; an assembler starts with assembly language and produces machine code.
- A learner may believe: “Each assembly instruction becomes many machine-code instructions.” Respond: It becomes one: each mnemonic is one machine-code instruction.
On the board or with the pen
- Write LOAD 5 → 0001 0101 and ADD 6 → 0010 0110 with the instruction code and the address underlined in two colours.
What learners should notice
- Assembly is words for the CPU’s own instructions.
- The binary for the number is four bits, as in the table.
Checking understanding: The assemble-it table and what-assembler-does check; ask pupils to explain how they looked up each part.
Depending on the answers
- If pupils write the wrong binary for the address: ask them to convert the number to 4 bits separately first.
- If answers are secure: ask pupils to translate machine code back into assembly.
English as an additional language
- Check mnemonic and assembler; relate mnemonic to ‘memory aid’.
In the lesson window
- Think it through: Without being told, what do you think the assembly instruction ADD 5 asks the CPU to do, and how could a program turn it into 0s and 1s?
- Check your understanding: What does an assembler do?
4. Two ways to translate Predict 14 min
On the lesson window now
Purpose: Pupils compare two ways of translating a French speech by predicting which starts sooner, what happens at an untranslatable sentence and what happens on a repeat, so that compiler and interpreter are met as ideas first.
Ask
- Which way starts sooner?
- What happens when a sentence cannot be translated?
- What is it like if the speech is to be given again?
- Does a compiler run the program?
Responses to expect
- Translating beside the speaker starts at once
- It stops there, after the earlier sentences have been translated
- The beside-the-speaker translator is needed each time; the written translation can be used again
- No: it only translates; the program runs afterwards as the executable file
Misconceptions to challenge
- A learner may believe: “A compiler runs the program line by line.” Respond: Use the misconception callout: a compiler translates the whole thing first and does not run it.
- A learner may believe: “A compiler needs to be present whenever the program runs.” Respond: Once translated, the executable runs without the compiler.
- A learner may believe: “An interpreter reports all errors before anything runs.” Respond: It stops at the first error it meets, after earlier lines have run.
On the board or with the pen
- Draw two timelines: one with translate everything then run, one with translate, run, translate, run.
What learners should notice
- Compiler: translate all, then run. Interpreter: translate and run each line.
- The written translation can be reused; the live one cannot.
Checking understanding: Pupils answer the speech questions on whiteboards; check the three differences (start, error, repeat).
Depending on the answers
- If pupils swap the two methods: ask which method needs the speech to be finished first and map it to the compiler.
- If answers are secure: ask what each method means for a program with an error on line 20 of 100.
English as an additional language
- Check translate, compile and interpret; act the two methods with volunteers.
Discussion pause: Pairs predict the answers to the three speech questions before the StepThroughs.
In the lesson window
- Think it through: Compare the two ways. Which one starts sooner? What happens if there is a sentence that cannot be translated? And what is it like if the speech is to be given again?
5. Which translator would you choose? Explain 8 min
On the lesson window now
Purpose: Pupils sort statements into compiler and interpreter to fix the contrast as properties, not names.
Ask
- Does each statement describe a compiler or an interpreter?
- What clue tells you each time?
- Which one needs the source code every time the program runs?
Responses to expect
- Whole-program translation: compiler; stops at first error: interpreter
- Whole versus line by line
- The interpreter
Misconceptions to challenge
- A learner may believe: “A compiler stops at the first error and has to be re-run each time.” Respond: A compiler reports errors for the whole code after translating; it is the interpreter that stops at the first error as it runs.
- A learner may believe: “Both produce an executable file.” Respond: Only a compiler produces one.
On the board or with the pen
- Fill in the two-column compiler versus interpreter table from the pupils’ sorting.
What learners should notice
- Use the clue words whole, line, stops, executable.
Checking understanding: The translator-sort table; ask pupils to give the clue word for each.
Depending on the answers
- If pupils confuse stopping behaviour: rerun the interpreter StepThrough and ask what had already run.
Support
- Provide clue words on cards.
English as an additional language
- Check executable, source code and translate.
6. Development and the final program Apply 14 min
On the lesson window now
Purpose: Pupils choose a translator for development and for release and correct a false account, applying the contrast to realistic situations.
Ask
- Which translator suits beginners who try a few lines at a time?
- Why compile a finished game for thousands of customers?
- What is wrong with the pupil’s account of a compiler running the program and stopping on line 3?
Responses to expect
- An interpreter, because it runs line by line and stops at the error
- The executable runs without the compiler or the source code and runs quickly
- It describes an interpreter: a compiler translates everything first and reports errors without running
Misconceptions to challenge
- A learner may believe: “A compiler is best for beginners because it produces an executable file.” Respond: An executable is useful for the finished program. Ask what beginners need while still testing a few lines.
- A learner may believe: “A compiler never needs to be present when they test.” Respond: That is a strength for the finished program, but beginners are still testing.
- A learner may believe: “Compilers always run the lines before an error.” Respond: A compiler translates the whole code before anything runs.
- A learner may believe: “Compilers cannot report line numbers.” Respond: They do report where errors are; ask which translator runs a line at a time.
On the board or with the pen
- Write development → interpreter and release → compiler on the board with a reason beside each.
What learners should notice
- The best translator depends on the stage: development or release.
Checking understanding: Show-me answers on all three questions; ask pupils to justify a wrong option as someone who has mixed up the two.
Depending on the answers
- If pupils choose a compiler for the beginners: ask what they need to see when a line is wrong and when it is seen.
- If answers are secure: ask which translator a company would use to distribute software without sharing its code.
Stretch
- Why might a company sell compiled software and keep the source code private?
English as an additional language
- Offer the frame: Use a ___ because ___.
Discussion pause: Pupils decide the beginners’ question before reading the options.
In the lesson window
- Apply it: A group of beginners is writing short programs and often makes mistakes. They want to try a few lines at a time, and to see exactly where each program goes wrong. Which translator is best for them at this stage, and why?
- Apply it: A company has finished a game and will sell it to thousands of customers. Which statement best explains why it should be compiled?
- Apply it: A pupil says: “My compiler ran my program and then stopped at the error on line 3.” What is the most likely mistake in this account?
7. Tools for writing code Discover 10 min
On the lesson window now
Purpose: Pupils suggest improvements to a clumsy editor-translator workflow, so that an IDE is met as a set of tools, not a synonym for a translator.
Ask
- Suggest two things a better tool could do for the pupil.
- Which IDE function is each description?
- Is Ravi right that an IDE is just another word for a compiler?
Responses to expect
- Highlight code, suggest words, put translator and output beside the editor, point to errors
- Editor, run-time, translator, diagnostics, completion, correction
- No: an IDE contains a translator and other tools such as an editor and diagnostics
Misconceptions to challenge
- A learner may believe: “An IDE and a compiler do the same single job.” Respond: A compiler turns source code into machine code; ask what else an IDE provides, such as an editor and diagnostics.
- A learner may believe: “An IDE is an operating system because it runs the program.” Respond: An IDE runs on the operating system like any application.
On the board or with the pen
- List the IDE functions down the side and write what each does.
What learners should notice
- An IDE gathers tools in one place.
- Diagnostics point to where an error is.
Checking understanding: The ide-match table; ask pupils which function would have helped most in the pupil’s clumsy workflow.
Depending on the answers
- If pupils choose the ‘same job’ option for Ravi: ask what a compiler cannot do (edit text, show a red line) and which tool does.
English as an additional language
- Check editor, diagnostics and completion; show an IDE on screen.
In the lesson window
- Think it through: What could be done to make this whole process faster and less error-prone for the pupil? Suggest two things a better tool could do.
- Apply it: Ravi says: “An IDE is just another word for a compiler.” What is the best reply?
8. Show what you know Consolidate 12 min
On the lesson window now
Purpose: Pupils explain the route from source code to the CPU for a compiler and an interpreter, then choose one, and recall what an assembler does.
Ask
- Explain the route from source code to the CPU carrying it out, for a compiler and for an interpreter, and say which you would use for sharing the program.
- Which statement about translators is correct?
Responses to expect
- Compiler: translate the whole to an executable, then run it; interpreter: translate and run line by line; compile to share
- An assembler translates assembly language into machine code
Misconceptions to challenge
- A learner may believe: “An assembler translates high-level code, or an interpreter makes an executable.” Respond: An assembler handles assembly language; only a compiler produces an executable.
On the board or with the pen
- Write pupils’ two routes as flow lines, source code to executable to CPU, and source code to line-by-line to CPU.
Checking understanding: Collect explanations; check the whole-versus-line contrast and a justified choice.
Depending on the answers
- If explanations name the translators without the route: ask when the translation happens in each.
- If answers are strong: ask what each choice means for the pupil who receives the program.
Support
- Offer a frame: A compiler ___, then ___. An interpreter ___, so ___.
English as an additional language
- Allow a flow diagram with labels in place of sentences.
Discussion pause: Two minutes of silent writing before pairs compare.
In the lesson window
- Think it through: A pupil has written a program in a high-level language and wants other people to be able to run it. Explain the route from the source code to the CPU carrying it out, for a compiler and for an interpreter, and say which you would use for the final program.
- Check your understanding: Which statement about translators is correct?
Lesson recap Closing
On the lesson window now
On screen: the lesson’s objectives again; Next adds the closing question, which asks the class to explain each one in their own words without looking back. It says nothing about what anyone has learnt: use the answers to decide what to revisit.
Points to listen for
- Ask pupils to complete a table from memory: high-level, low-level, assembly, compiler, interpreter, assembler, IDE, each with one job or property.
- Take the mistaken ‘compiler ran my program and stopped at line 3’ and ask pupils to explain in two lines what really happened.
- Look ahead: the next lesson is about automated systems and robotics, so ask pupils which language level they would expect for a program that controls a motor.
- Ask pupils to write one question they still have about translators.
Consolidation
- Ask pupils to complete a table from memory: high-level, low-level, assembly, compiler, interpreter, assembler, IDE, each with one job or property.
- Take the mistaken ‘compiler ran my program and stopped at line 3’ and ask pupils to explain in two lines what really happened.
- Look ahead: the next lesson is about automated systems and robotics, so ask pupils which language level they would expect for a program that controls a motor.
- Ask pupils to write one question they still have about translators.