CS18 : Translation, please!

In this section, we will learn more about system software but specifically the software which allows us to give computers instructions.

We are learning ...
  • About the main generations of programming languages
  • About the features of IDE's and why they are useful
  • About the ways in which different language translators work
So that we can ...
  • State the different generations of programming language (low and high level)
    - Advantages of low and high level languages
    - Standardisation and portability
    - Intermediate languages (bytecode)
  • Explain the operation of different language translators (interpreters, compilers, assemblers)
    - Features and differences
    - Source code and object (executable) code
  • Discuss IDE's and their features
  • Discuss the different systems which convert programming languages into machine code
    - Lexical analysis, symbol table construction, syntax analysis, semantic analysis, code generation and optimisation, linkers, loaders and libraries

Activity 1 Programming language generations

Programming languages are grouped in 'generations' depending on where they are in relation to the computer and also how close to the problem domain they lie. The higher the generation, the further removed the programming language is from the hardware and the closer it is to the problem.

Click to view

Programming languages are broadly divided into low and high level languages.

Low level
  • Close to the hardware and machine dependent;
  • Generally not portable between machine architectures;
  • Provide fast, efficient execution;
  • Utilise advanced hardware features not available in HLL.
  • Generally quite complicated to write;
  • 1:1 mapping of assembly language and machine code;
  • Considered to be machine code (1st) and assembly language (2nd).
High level
  • Are generally further from the machine and closer to the problem;
  • Are generally portable between machine architectures;
  • Often less efficient / slower solutions since the implementation is quite generic;
  • Generally straightforward to write;
  • Generally 1:Many mapping of high level language statement to machine code.
  • Include procedural / imperative languages and declarative languages.

Task 1.1
 Drawing diagrams
Inventive brain

There is a diagram and a list of statements above. Your job, if you choose to accept it, is to present the information in a different way that will help you to remember it. You should copy the popup diagram and could convert the two lists about low and high level languages into a colourful 'comparison' poster

OUTCOME : An inventive display.

Integrated development environments

Assembly code and the high level languages are generally written using Integrated Development Environments (IDEs), although it is theoretically possible to write most high level languages using Notepad, though it's not always the most sensible way. Modern IDE's are feature rich and are designed to help the programmer to efficiently and accurately. You will be familiar with IDLE - Pythons IDE but there are many others.

Task 1.2
Geany IDE

If you can, open up Geany or Geany Portable. In the resources for this lesson, there is a Python script called Guessing Game. Open this script, using Geany and then try to identify the features I have described in the screenshot below.

  1. Function list
  2. Compiler / interpreter status messages
  3. Code folding
  4. Syntax highlighting
  5. Compile and execute functions;
  6. Search
... plus, there are many others.

Investigate the features of IDE's and make a list in your notebooks. Explain why each of the features is useful.

OUTCOME : A detailed list of IDE features with justification of why they are useful.

Activity 2 Languages translators

Computer hardware / processors only understand machine code - binary strings of 0's and 1's which represent instructions and data. Originally, computers were programmed using switches - literally switches to instruct the computer using 0's and 1's. Eventually when that became a little tedious, programmers invented higher level languages which were more like English but they needed to be converted into machine code before the computer could execute them.

Watch the groovy video about high level language translators - it's groovy, but that's because it's old, like me :)

This video doesn't explain how an assembler works. Here is a video using a Commodore 64 Assembler to create a famous 'Hello World' message. Persevere with the video - it's is worth it, honest!

The assembler works in a similar way to a compiler - converting all the assembly code into machine code before it is executed. If you don't really follow this, don't worry - we'll look more closely at assembly code in 'Who is this little man?'.

Task 2.1
 Gapped activity

Copy and complete the gapped activity using the words in the list. Highlight the words you have entered using a highlighter pen so that it is easy for me to check your answer.

executable, high, does not, machine, one, whole, translates

"There are three types of translator. A compiler translates code written in a _____(1)_____ level language to _____(2)_____ code. It translates the _____(3)_____ source code into object code and saves it in an _____(4)_____ file that can be run later. An interpreter also translates code written in a high level language to machine code but works differently. It translates and immediately executes _____(5)_____ line of code at a time and _____(6)_____ produce saved object code. Finally, an assembler _____(7)_____ each assembly language instructions into a machine code instruction."

OUTCOME : Completed activity with the missing words highlighted so that you can see them and I can mark them to check that they are correct.

Stages of compilation

Compilers are very complex pieces of software written to parse high level programming languages and convert them into machine code. The principal stages in compilation are ...
  • Lexical analysis
  • Symbol table construction;
  • Syntax analysis;
  • Semantic analysis;
  • Code generation;
  • Code optimisation;
  • Linkers;
  • Loaders;
  • Libraries.

Task 2.2
 Flash cards
Internet for research only.
Card cut up into flash cards or equivalent.

Investigate the stages in compilation and try to write short, simple explanations. Transfer your findings onto flash cards which you can use for revision. Remember, if you don't understand it, don't write it.

OUTCOME : Set of flash cards which will help you revise for your exam.

I remember typing machine code into my Commodore 64 in the 1980s

Click to view


Bytecode is an intermediate instruction set that can be executed by a virtual machine rather than a physical one. Examples of bytecode interpreters are the Java virtual machine and Microsoft Common Intermediate Language (CIL). Bytecode is sometimes called p-code or portable code because it can be interpreted on many different machine architectures.

Task 2.3
World wide web

In your notebooks : Perform a Google image search for 'Bytecode Virtual Machine'. Use the images you find to create your own image which help to visualise what bytecode is.

OUTCOME : Image which describes the meaning of bytecode.

Extension Activities 
  • Print off the crossword and complete it. It's not that hard.


What's next?

Before you hand your book in for checking, make sure you have completed all the work required and that your book is tidy and organised. Your book will be checked to make sure it is complete and you will be given a spicy grade for effort.

Let's build a compiler : https://compilers.iecc.com/crenshaw/
Let's build an intepreter : https://ruslanspivak.com/lsbasi-part1/