CS06-05 Computer Science Watch
High-level and low-level languages
In this lesson
How to describe the characteristics of high-level and low-level languages and the main, with worked examples and the mistakes examiners report. AQA 8525, Edexcel 1CP2 and OCR J277 GCSE. Software and languages 5 of 8. Full Software and languages playlist: https://www.youtube.com/playlist?list=PLQW0s9-KegDg More at https://scholafly.com
By the end: Describe the characteristics of high-level and low-level languages and the main differences between them - closeness to English, portability, one statement to many machine instructions, direct control of hardware - give the advantages and disadvantages of each, explain why most programs are written in high-level languages, and explain why any program not written in machine code must be translated before the processor can run it.
What it covers
- 0:00 Intro: high-level and low-level languages
- 0:54 High-level and low-level languages: machine code
- 5:33 High-level and low-level languages: characteristics
- 12:24 Advantages and drawbacks
Key words
About this video
High-level and low-level languages | GCSE Computer Science | CS06-05
How to describe the characteristics of high-level and low-level languages and the main, with worked examples and the mistakes examiners report.
AQA 8525, Edexcel 1CP2 and OCR J277 GCSE. Software and languages 5 of 8.
Full Software and languages playlist: https://www.youtube.com/playlist?list=PLQW0s9-KegDg
More at https://scholafly.com
Video code: CS06-05 (search "ScholaFly CS06-05")
#GCSEComputerScience #SoftwareAndLanguages
For teachers
This GCSE Computer Science lesson teaches high-level and low-level languages. By the end, students should be able to describe the characteristics of high-level and low-level languages and the main differences between them - closeness to English, portability, one statement to many machine instructions, direct control of hardware - give the advantages and disadvantages of each, explain why most programs are written in high-level languages, and explain why any program not written in machine code must be translated before the processor can run it. It works through four worked examples and the mistakes examiners report.
Exam board specification references:
AQA 8525
- 3.4.4
Edexcel 1CP2
- 3.3.1
OCR J277
- 2.5.1
Read the transcript
Every app on your phone was written by a person typing lines such as this one: if the score is more than ten, add a life. Does your phone's processor run the language that app was written in? It feels as though it must. In fact the processor runs one language only, and that language is nothing but ones and zeros. It has no idea what a score is, or a life, or a word. Between the line a person types and the ones and zeros the processor runs, there is a gap to cross. Where a language sits across that gap decides what it is good for.
Start at the processor's end of the gap. A processor carries out instructions stored in memory, and every one of them is in binary, the number system that uses only ones and zeros. Those binary instructions have a name. Machine code is instructions written in binary that the processor can execute directly, meaning carry out with no translation. If the idea of instructions in memory feels shaky, the video on the CPU and the von Neumann model covers it. Now go to the other end of the gap, where the person is. A programming language is a set of words and rules that a person uses to write instructions for a computer. Picture a ladder across the gap. The person stands at the top, the processor sits at the bottom, and each programming language has its own rung. A language's level is how close its rung sits to the person or to the processor. A high-level language is a programming language that is close to human language and is not written for any one type of processor. Python is a high-level language. A line of it reads almost like English: if score is greater than ten, print well done. Predict this one. The processor runs only machine code, and that Python line sits near the top of the ladder. What has to happen to the line before it can run? It has to be translated into machine code first. A translator is a program that converts code written in a programming language into machine code, so that the processor can carry it out. There is more than one kind of translator, and a later video in this chapter takes them one at a time. Here, the word translator is all you need. One examiner's report says many students clearly understood the need for high-level code to be translated into machine code before the processor can execute it. If you have that, you are in good company. Now the bottom of the ladder. A low-level language is a programming language that is close to the processor's own instructions, and is written for one type of processor or family of processors. There are two low-level languages to know. Machine code is the bottom rung, and assembly language is the rung just above it. How those two differ from each other is the job of the video called machine code and assembly language. Here, it is enough that both of them are low level. Now a question for you. A student writes that low-level languages never need translating. Is that right, wrong, or only half right? It is only half right. Machine code never needs translating, because the processor runs it directly. Assembly language is low level too, and it still has to be translated. One examiner's report says many students seem to think low-level language is the same as machine code, when machine code is only one example of a low-level language. In plain words, those students treated every low-level language as if it ran directly. That is true of machine code, and not of assembly language. The habit that fixes it is to write machine code by name whenever machine code is what you mean.
Every difference between the two levels comes from where a language sits on the ladder, near the person or near the processor. These differences are characteristics, meaning what each kind of language is like. What each is good for comes afterwards, and the two are kept apart because a question can ask for either. First, how it reads. A high-level language uses English-like keywords, words such as if, while and print. Low-level code is written in the processor's own instructions, so it is much harder for a person to read. Second, how much one line does. One high-level statement does the work of many machine code instructions. Take the line: total equals price times quantity. To carry it out, the processor fetches the price from memory, fetches the quantity, multiplies the two, and stores the total back in memory. That is around four instructions for one line. In a low-level language, the programmer writes out steps like those for themselves. Now a quick one. A high-level program is ten lines long. Once it is translated, do you expect fewer than ten machine code instructions, about ten, or many more than ten? Many more than ten. Each high-level statement does the work of several machine code instructions, so ten lines turn into far more than ten instructions. Third, where it can run. A program is portable when the same program can be made to run on different types of processor. A high-level language is portable, because translators exist for many different types of processor. The program stays the same, and each type of processor gets its own translator. A low-level language is written in one processor's own instructions, so it runs only on that type of processor or its family. To run anywhere else, it has to be rewritten. Fourth, control. A low-level language gives the programmer direct control of the hardware, down to which instruction runs and where in memory each value goes. A high-level language hides those details, and the translator makes those choices instead. A question that asks for these differences reads: give three ways a high-level language differs from a low-level one. A student writes three answers. A reads: high-level languages are easier. B reads: low-level languages do not need to be translated. C reads: a high-level program can be translated to run on different processors, while a low-level one runs only on the processor it was written for. Which of the student's three answers is right as it stands, A, B or C? Take your pick before the reveal. C is right. It names a real difference, portability, and says what each side does. Now say why. What stops answer A from being good enough as it stands? Answer A never says what is easier, or why. A difference needs both sides and a reason: high level is easier to read because it uses English-like keywords, while low level uses the processor's own instructions. A full answer gives three differences, each with both sides. High level reads like English, while low level uses the processor's instructions. One high-level statement does the work of many machine code instructions. High level is portable, while low level is tied to one type of processor. One examiner's report on a question about these differences says the incorrect responses tended to be on the first row of the answer table, the one about portability. In plain words, students mixed up which level is portable, saying high level is tied to one processor, or that low level runs anywhere. The fix is to tie portability to the processor every time. High level is portable because translators exist for many processors, and low level is written for one. Now a longer one. A program written in a high-level language runs on a laptop. Explain why it must be translated before the laptop's processor can run it, and why the same program can also be made to run on a phone with a different processor. Try it on paper before I show you the answer. First, the translation. The chip inside the laptop executes only machine code, so a translator converts the code into machine code before anything happens. Second, the phone. The phone's processor has different instructions, so the same high-level program goes through a translator made for the phone's processor instead. The program itself does not change. The translator does the part that depends on the processor, and that is what makes a high-level language portable.
Now the question changes from what each level is like to what each level is good for. High level is better for the programmer, and low level can be better for the processor. Start with high level. It is quicker to write, because it uses English-like keywords and one statement does the work of many instructions. Debugging means finding and fixing the errors in a program. High level is easier to debug and maintain, because a person can read it, find a mistake and change it. The drawback of high level is that it must be translated, and the machine code a translator produces may not be as efficient as code written by hand for that processor. That means it can run slower and use more memory. Now low level. It can run faster and use less memory, because the programmer writes for that exact processor and chooses every instruction. It also gives direct control of the hardware. Its drawbacks are that it is slow to write and hard to debug, because it is hard to read, and it is not portable. Here is a different one. A question asks for one advantage of writing a program in a low-level language instead of a high-level one. Which fits: A, it is easier to debug; B, it can run faster because it is written for that processor's own instructions; or C, it can run on any type of processor? B is the one that fits. It is an advantage of low level, and it carries its reason with it. Now say why A is wrong. Easier to debug is a true statement about languages, so what is wrong with giving it here? It is the wrong way round. Easier to debug is an advantage of high level, and the question asked about low level. Answer C is false, because low-level code is tied to one type of processor. One examiner's report on a question like this one says many students appeared to misread the question and gave advantages of writing in a high-level language. The fix is to find the direction before you write. Decide which language the question wants the advantage of, and answer from that side only. When the question says explain, the reason carries the answer. Faster on its own is a claim. Faster because the programmer chooses every instruction for that processor is an explanation. Put the two sides together, and you can see why most programs are written in a high-level language. They are quicker to write and easier to fix and change, and one program can run on many types of processor. For most software, the programmer's time costs far more than the processor's time. A language that saves the programmer days is a good trade for a little speed. Low level is chosen when that trade flips: when code must control one hardware component directly, when memory is very limited, or when a routine must run as fast as possible. A quick check before the bigger one. Which of these pushes a programmer towards low level: an app for many kinds of phone, a routine that drives one sensor directly, or an app that has to be finished in a week? The sensor routine. It needs direct control of one hardware component. The other two call for high level, because one needs portability and the other needs speed of writing. Embedded systems, the small computers built into devices such as washing machines, are one place where low-level code is used. The embedded systems video covers what they are. One examiner's report, the same one that praised students for knowing high-level code must be translated, goes on to say the questions specifically asked for reasons and benefits. In plain words, many answers explained what the levels are without giving a reason to use one. The better answers gave reasons for low-level code, such as direct control of hardware and faster execution of code. Check what the question is asking for. If it asks for differences, give what each level is like. If it asks for reasons, give what a level is good for, with its because. Now a bigger one. A games company is writing software for a new handheld console with a very small amount of memory. One programmer wants a high-level language, and another wants a low-level one. Give one reason for each choice, and say which you would choose for most of the program. Pause it there and work it out for yourself. For low level: the console has very little memory, and low-level code written for its processor can use less memory, because the programmer chooses every instruction. For high level: the game will be quicker to write and easier to debug, because the code uses English-like keywords, so the team finishes sooner. For most of the program, high level is the better choice. Low-level code is kept for the parts that must be tiny or fast, or that control the console's hardware directly. Each of those reasons names the console and its small memory. A reason tied to the device in the question says more than one that would fit any computer.
To close, four questions, one at a time. Say each answer out loud first.
First, why must a program written in a high-level language be translated before it runs? Because the processor can execute only machine code, and a high-level program is not machine code. A translator converts it first.
Now the second. A student says low-level code always runs directly. Which low-level language proves them wrong? Assembly language. It is low level, but it still has to be translated, because only machine code runs directly.
Now one the video has not shown. A smart doorbell has a tiny memory, and one routine must control its camera chip directly. High level or low level for that routine, and why? Low level, because it gives direct control of the hardware, and code written for that one processor can use less memory.
Now the last one, in your own words. Why are most programs written in high-level languages? They are quicker to write and easier to fix, they can run on many types of processor, and the programmer's time costs more than the processor's.
So the processor in your phone never runs the app's language at all. A translator turns the line about the score into machine code first, and where a language sits on the ladder decides what it is good for.
If you could teach this one to a friend, give it a thumbs-up. If it has not landed yet, save it: the rest of the chapter keeps climbing this ladder, so it comes back round.
Next in the chapter is Machine code and assembly language. Hopefully that's next in your feed, but if not, search for ScholaFly C S oh six, oh six.
Every other video is on scholafly.com too, easy to search by video code or by keyword. Whatever you're revising, go there and have a look, or, watch the next video.
Related terms
For: AQA GCSE 8525, Edexcel GCSE 1CP2, OCR GCSE J277
On the specification
For teachers
This GCSE Computer Science lesson teaches high-level and low-level languages. By the end, students should be able to describe the characteristics of high-level and low-level languages and the main differences between them - closeness to English, portability, one statement to many machine instructions, direct control of hardware - give the advantages and disadvantages of each, explain why most programs are written in high-level languages, and explain why any program not written in machine code must be translated before the processor can run it. It works through four worked examples and the mistakes examiners report.