0% found this document useful (0 votes)
11 views28 pages

Programming Languages and Translators Overview

The document covers the classification of programming languages, distinguishing between low-level and high-level languages, and the need for translation via interpreters, compilers, and assemblers. It explains the differences between machine code and assembly language, highlighting their specific uses and advantages. Additionally, it discusses the characteristics and functionalities of various programming languages and their respective translators.

Uploaded by

pratultapase0
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views28 pages

Programming Languages and Translators Overview

The document covers the classification of programming languages, distinguishing between low-level and high-level languages, and the need for translation via interpreters, compilers, and assemblers. It explains the differences between machine code and assembly language, highlighting their specific uses and advantages. Additionally, it discusses the characteristics and functionalities of various programming languages and their respective translators.

Uploaded by

pratultapase0
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

Classification of programming languages and translators

Unit 4 Computer systems

Starter
• Name five programming languages
• Are there any major differences between each of them?
Objectives
• Understand and be able to give the advantages and
disadvantages of the different levels of programming
language, including:
• Low-level languages
• High-level languages

• Be able to explain the differences between machine


code and assembly language
• Understand the need to translate high-level or
assembly languages
• Be able to explain the differences between
interpreters, compilers and assemblers
Classification of programming languages and translators
Unit 4 Computer systems

Starter
• High-level Programming languages
• Python, Visual Basic, C#, Java, C++, PHP, Delphi, Logo

• Query languages
• SQL

• Markup languages
• HTML, XML

• Low-level Programming languages


• Assembly language
Classification of programming languages and translators
Unit 4 Computer systems

Machine code
• Computers were first invented in the 1940s
Classification of programming languages and translators
Unit 4 Computer systems

Machine code
• In the first computers, all programs were written in
machine code
• Instructions were written in binary, so a typical
instruction looked like this:
101011001001
• Each instruction did one very small task like
LOAD the value 1 into the accumulator register
• Writing programs was difficult and time-consuming
Classification of programming languages and translators
Unit 4 Computer systems

Machine code and processors


• Processors can still only execute instructions in
machine code
• Processors have different types such as:
• Intel i7 used in a powerful PC
• Samsung Exynos 990 used in a Samsung S20
• Apple A13 Bionic used in iPhone 11

• The machine code instructions will be


specific to a particular processor or
family of processors
• This is why a program written for a PC
won’t run on an Apple or Samsung smartphone
Classification of programming languages and translators
Unit 4 Computer systems

Assembly language
• Assembly language allows a programmer to create
programs more easily that writing in machine code
• Each assembly language instruction maps directly to
machine code
• For example:
1000101100000100001001010011001
LDA 51
1000000000000000000000000000001
ADD #FF 01111111110000000000000000000000
0010001001000001000010010100110
STO 52 10000000000
Assembly language Machine code
means “Load the contents of memory location 51 into the
accumulator, add hexadecimal value FF and store the result
in location 52”
Classification of programming languages and translators
Unit 4 Computer systems

Assembly languages
• Assembly language is also processor-specific
• It has to be translated into machine code before it
can be executed
• There is a 1:1 correspondence between assembly language
and machine code
• Both machine code and assembly language are
considered to be low-level languages
• Programs written in assembly language must be
translated to machine code in order to be run
• The program that does this is known as an assembler
Classification of programming languages and translators
Unit 4 Computer systems

Assembly language uses


• Today, assembly language is
typically only used for the
following types of software:
• Software used in embedded
systems, such as a washing
machine or microwave oven
• The software used to control
specific hardware components
such as device drivers
Classification of programming languages and translators
Unit 4 Computer systems

Assembly language uses


• Assembly language allows the programmer to
precisely control any instruction on the processor
• This means that programs can be made to be very efficient
• For instance, when a graphics device driver is programmed to
run quickly and make use of all the advanced features
Classification of programming languages and translators
Unit 4 Computer systems

High-level languages
• High-level languages generally have statements that
look a bit like English or Maths
area = (base * height) / 2
print(area)
• This makes these
languages easier to
learn and understand
Classification of programming languages and translators
Unit 4 Computer systems

High-level languages
• High-level languages also have data structures such
as arrays and records
• Many high-level languages have been especially
designed to make it as easy as possible to write
programs to solve certain types of problem
• These languages must be translated into machine code in
order to run
• A single statement usually translates into several machine
code instructions
• The translation is done by a program which may be
either a compiler or an interpreter
Classification of programming languages and translators
Unit 4 Computer systems

Machine independence
• A program written in a high-level language such as
Python or VB, for example, can be run on different
types of processor with very few changes, if any, to
the program statements
• A different compiler or interpreter is used for each type of
processor to translate the source code (written by the
programmer) into machine code for that processor
Classification of programming languages and translators
Unit 4 Computer systems

High- and low-level languages


Classification of programming languages and translators
Unit 4 Computer systems

High-level advantages
• There are a number of advantages of high-level
languages, including:
• A high-level language is easier to learn
• Programs can be written faster in a high-level language
• It is easier to understand and debug a high-level language

• Given all these advantages, why do you think that


low-level languages are still used by
some programmers?
Classification of programming languages and translators
Unit 4 Computer systems

Low-level advantages
• As a programmer has direct control over how a low-
level program works they have a number
of advantages, including:
• A program written in a low-level language can run very quickly
• The code will usually require less RAM
• Statements in a low-level language can be used to control
and manipulate specific hardware components
• As such, programs such as device drivers are often
written in assembly code
Classification of programming languages and translators
Unit 4 Computer systems

Worksheet 3
• Now complete Task 1 on Worksheet 3
Classification of programming languages and translators
Unit 4 Computer systems

Translators
• A translator is
someone who
translates from one
language to another
• A translator program translates from one
programming language to another one
• There are three types of program translator:
• Interpreter
• Compiler
• Assembler
Classification of programming languages and translators
Unit 4 Computer systems

Compiler
• A compiler translates a high-level language into
machine code
• The code written by the programmer is called the source code

Source code Machine code


score = score + 5 COMPILER 01011 001 00101
total = 10 00010 001 01010

• The machine code produced can be saved on a


storage device and run whenever required
Classification of programming languages and translators
Unit 4 Computer systems

Interpreter
• An interpreter is another type of program that
translates a high-level language into machine code
• Unlike a compiler, no object code is produced
• It translates each line of code and executes
it immediately
• If it reaches a line with a syntax error, it stops and displays an
error message
Classification of programming languages and translators
Unit 4 Computer systems

Assembler
• When assembly code is written it first needs to be
translated into machine code
• An assembler translates assembly code to machine code

Assembly code Machine code


ADD R1, #5 ASSEMBLER 01011 001 00101
MOV R1, #10 00010 001 01010
Classification of programming languages and translators
Unit 4 Computer systems

Translators compared
Feature Interpreter Compiler Assembler
Input A high-level language A high-level Assembly
language language
Output No output – program Machine code Machine code
runs straight away
How it works Translates source Compile source Assemble source
code and immediately code so it can be code so it can be
run it run later run later
Speed of Slow as needs to be Fast as it just runs Fast as it just runs
execution translated each time it the machine code the machine code
is run
What end users Each end user needs Users need just Users need just
need to run the interpreter and the the compiled the compiled
program program program program
Source code End user can see the End user can’t see End user can’t see
source code the source code the source code
Classification of programming languages and translators
Unit 4 Computer systems

Compiler or interpreter?
• Some languages, such as Java, are compiled into
an intermediate stage called bytecode
• The bytecode can be interpreted on many different types of
processor using an interpreter
• Javascript, used in creating web pages, is
interpreted; the source code is included in the web
page and then interpreted in the browser (e.g.
Firefox, Chrome, Internet Explorer)
Classification of programming languages and translators
Unit 4 Computer systems

Worksheet 3
• Now complete Task 2 on Worksheet 3
Classification of programming languages and translators
Unit 4 Computer systems

Plenary
• Complete the following by filling in the blanks
__________ languages include __________, VB and
C#. They need to be __________ or interpreted before
they can be run. __________ is a low-level language.
It is __________ into __________ before it is run.
Compiled Assembly language Machine code
Python High-level assembled
Classification of programming languages and translators
Unit 4 Computer systems

Plenary
• Complete the following by filling in the blanks
High-level languages include Python, VB and C#.
They need to be compiled or interpreted before they
can be run. Assembly language is a low-level
language. It is assembled into machine code before it
is run.
Compiled Assembly language Machine code
Python High-level assembled
Classification of programming languages and translators
Unit 4 Computer systems

Copyright

© 2020 PG Online Limited

The contents of this unit are protected by copyright.

This unit and all the worksheets, PowerPoint presentations, teaching guides and other associated files
distributed with it are supplied to you by PG Online Limited under licence and may be used and copied by you
only in accordance with the terms of the licence. Except as expressly permitted by the licence, no part of the
materials distributed with this unit may be used, reproduced, stored in a retrieval system, or transmitted, in any
form or by any means, electronic or otherwise, without the prior written permission of PG Online Limited.

Licence agreement

This is a legal agreement between you, the end user, and PG Online Limited. This unit and all the worksheets,
PowerPoint presentations, teaching guides and other associated files distributed with it is licensed, not sold, to
you by PG Online Limited for use under the terms of the licence.

The materials distributed with this unit may be freely copied and used by members of a single institution on a
single site only. You are not permitted to share in any way any of the materials or part of the materials with any
third party, including users on another site or individuals who are members of a separate institution. You
acknowledge that the materials must remain with you, the licencing institution, and no part of the materials may
be transferred to another institution. You also agree not to procure, authorise, encourage, facilitate or enable any
third party to reproduce these materials in whole or in part without the prior permission of PG Online Limited.

You might also like