Information Technology Topic

Low-Level and High-Level Languages

  1. Read notes
  2. Flashcards
  3. Quiz
  4. Confident

Study focus - 3 things

  1. Machine language is binary that the processor can carry out directly. Assembly language swaps the binary for short mnemonics that an assembler translates. Both are low-level and tied to one type of processor
  2. A high-level language such as Pascal or C uses English-like statements, is quicker to write, read and fix, and is translated by a compiler. One statement usually becomes several machine instructions
  3. Compare the two groups on closeness to the hardware, ease of use, control and speed, portability and the translator needed. Low-level does not mean poor quality, it means close to the hardware

Section 1Languages come in levels

A processor can only follow instructions written in its own binary patterns. People find binary painful to write, so other languages were made that suit people better. We describe them by their level. The level tells you how close the language is to the hardware. A low-level language sits close to the machine. A high-level language sits close to the way people think and hides the hardware. For the syllabus, the low-level languages are machine language and assembly language. The high-level languages named are Pascal and C. Here's the trick: low does not mean poor quality. It only means close to the hardware.

Section 2Machine language

Machine language is the set of instructions written as binary patterns (0s and 1s) that the processor can carry out directly, with no translation. Each type of processor has its own set of instructions. A machine-language program written for one type of processor will not work on a different type. Writing in it means long rows of 0s and 1s. One wrong digit changes the meaning of an instruction, and nobody can read a program by just looking at it. Very few programmers write it by hand. Still, whatever language a program starts in, it must end up as machine language before the processor can run it.

Section 3Assembly language

Assembly language is a step up from binary. It uses short, readable codes called mnemonics, such as ADD or STORE, and names for the values being used. A program called an assembler translates assembly language into machine language. Each assembly instruction becomes one machine instruction, so assembly language is still close to the hardware and still tied to one type of processor. Assembly-style example (the mnemonics are invented for teaching, real ones differ for each processor): LOAD price MULTIPLY qty STORE total Easy to mix up: assembly language is not machine language. It is a readable form of it that must be translated first.

Section 4High-level languages

A high-level language lets you write statements that look a little like English and algebra, without dealing with binary patterns or the detail of the processor. Pascal and C are the examples the syllabus names. The same job as the three assembly lines above is one line in Pascal-style code: total := price * qty; When a statement like this is translated, it usually becomes several machine instructions. The translator for a high-level language is called a compiler. The program the programmer types is the source code. The machine-language version that the compiler produces is the object code. A high-level program must be translated before the computer can run it.

Section 5Side by side

Closeness to the hardware: low-level languages are close, so the programmer controls the processor in detail. High-level languages hide the hardware. Ease of use: low-level code is slow to write and hard to read and debug. High-level code is quicker to write and easier to read, test and maintain. Speed and size: carefully written low-level code can be very fast and small. The same job in a high-level language usually takes more instructions. Portability: low-level code is tied to one type of processor. A high-level program can be moved to a different type of computer if that computer has a suitable compiler. We say it is portable. Translator: machine language needs none, assembly language needs an assembler, a high-level language needs a compiler.

Section 6Choosing the right level

Most programs are written in a high-level language because the programmer's time is the expensive part. A mark-book program for a school in Portmore, a stock program for a shop in Mandeville, a booking screen for a Montego Bay call centre: all sensible jobs for Pascal or C. Low-level code is chosen when the programmer needs close control of the hardware, or needs a very small and fast program. Examples are the tiny program inside a simple machine, or a part of the system software that talks straight to a device. In an exam, name the need (ease, speed, control or portability) and match it to a level. It is a trade-off, not a contest.

Section 7Translators between the levels

A language translator is a program that takes a source program and turns it into a machine-language object program. Assemblers and compilers are the two you need to know. Machine language needs no translator. Assembly language goes through an assembler. A high-level language goes through a compiler, which works on the whole program and produces object code that can be run later. The pattern is simple: the further the language is from the hardware, the more work the translator does. The topic on the steps in implementing a program shows where this translation fits when a program is built and run.

Examples

A student in Kingston is shown four items from different programs. Item A: 10110001 00001100 (an invented bit pattern) Item B: LOAD price (assembly-style, invented for teaching) Item C: total := price * qty; (Pascal-style) Item D: total = price * qty; (the same job in C) (a) State the type of language of each item: machine, assembly or high-level. (b) Name the translator needed for items B and C, and say whether item A needs one. (c) State which items a new programmer would find easiest to read, and why.

(a) Item A is only 0s and 1s, so it is machine language. Item B is a mnemonic (LOAD) with a name, so it is assembly language. Items C and D are statements that look like algebra with named values, so they are high-level (Pascal and C). (b) Item B needs an assembler. Item C needs a compiler (item D needs one too). Item A needs no translator because the processor can carry it out directly. (c) Items C and D. One statement does the whole job and reads like the maths. Item B is readable but takes three instructions for the same job, and item A cannot be understood without looking up every pattern.

Two projects are planned. Project 1: a mark-book program for a school in Mandeville. Teachers will keep updating it, and it may later be moved to newer office computers. Project 2: a very small program inside a simple machine. It must fit into a tiny amount of memory and control one device directly. (a) Recommend a type of language for each project. (b) Give two reasons for each recommendation. (c) State one disadvantage of the type of language you chose for Project 2.

(a) Project 1 should use a high-level language such as Pascal or C. Project 2 should use a low-level language, for example assembly language. (b) Project 1: the code is easier to read, test and update when teachers' needs change, and it is portable, so it can be moved to the newer computers with a suitable compiler. Project 2: the programmer controls the device directly, and the program can be made small and fast to fit the little memory available. (c) Low-level code is slow to write and hard to read and debug. It is also tied to that type of processor, so it would have to be rewritten for a different one.

Now let's water it

Session runs notes to flashcards to quiz back-to-back.

Where this comes from