0% found this document useful (0 votes)
40 views

4.2 Languages

1) This document discusses different types of programming languages, including low-level languages like machine language and assembly language, and high-level languages. It also covers language translators like assemblers, compilers, and interpreters. 2) An IDE is described as providing code editing, debugging, translation, and other functions to facilitate program development. Common IDE features include code editors, runtime environments, error diagnostics, and autocomplete. 3) The roles of compilers and interpreters are summarized as compilers translating entire programs into executable files before running, while interpreters translate and execute code line-by-line, stopping on errors.

Uploaded by

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

4.2 Languages

1) This document discusses different types of programming languages, including low-level languages like machine language and assembly language, and high-level languages. It also covers language translators like assemblers, compilers, and interpreters. 2) An IDE is described as providing code editing, debugging, translation, and other functions to facilitate program development. Common IDE features include code editors, runtime environments, error diagnostics, and autocomplete. 3) The roles of compilers and interpreters are summarized as compilers translating entire programs into executable files before running, while interpreters translate and execute code line-by-line, stopping on errors.

Uploaded by

Ahmed Shakir
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

4.

2 Types of programming language, translators and integrated development


environments (IDEs)
Candidates should be able to: Notes and guidance
1 Explain what is meant by a high-level language and a • Advantages and disadvantages include:
low-level language, including the advantages and – ease of reading and writing code,
disadvantages of each e.g. low-level is hard to read
– ease of debugging code
– machine independence
– direct manipulation of hardware
2 Understand that assembly language is a form of low-
level language that uses mnemonics, and that an
assembler is needed to translate an assembly language
program into machine code
3 Describe the operation of a compiler and an • A compiler translates the whole code at once before
interpreter, including how high-level language is executing it, producing an executable file
translated by each and how errors are reported • An interpreter translates and executes the code line-by-
line
• A compiler provides an error report for the whole code
if errors are detected
• An interpreter stops execution when an error is found
4 Explain the advantages and disadvantages of a • To include an understanding that an interpreter is
compiler and an interpreter mostly used when developing a program and a compiler
is used to translate the final program
5 Explain the role of an IDE in writing program code • Including:
and the common functions IDEs provide – code editors
– run-time environment
– translators
– error diagnostics
– auto-completion
– auto-correction
– prettyprint

Programming Language:
“A set of rules that provide a way of telling computer what operation to perform is called a
Programming Language.”
A COMPUTER PROGRAM is a list of instructions that enable a computer to perform a
specific task. Computer needs instructions to perform a task.
There are some rules and regulations to write programs and these rules and regulations are
programming languages.
Different types of programming languages are given below:
1. Low Level Language (Machine Language and Assembly Language)
2. High level Languages

1) Machine Language: (Low Level Language) Machine Language Code


Machine languages are the most basic 000100101111010101001111010101
languages. They consist of a series of current signals
0100010010100001111101010101111
„On‟ and „Off‟. On is represented by „1‟ and off is
represented by „0‟. 0101000111110101011101100100110
It is 1st generation of language.
Machine language is also called Binary Digits. It is
computer‟s language in which different parts of computer Machine Language Code
communicate with each other. 0s and 1s are called bit
12EF A243 4EC2 33C2 3D23 4E23
(binary digit).
4FFA CA12 ACEF F234 DE12 F98A
Machine language is easy for computer and
difficult for programmer. Every computer has its own unique machine language. It means machine
for Apple Macintosh is different from IBM compatible.

2) Assembly Language: (Low Level Language)


Assembly language consists of English like symbolic codes known as mnemonics.
It is a second generation of language.
Mnemonics represent common strings of machine codes. A language translator, Assembler,
is used to convert source code of Assembly language program into object code of machine
language. Though Assembly languages are easier than
Assembly Code (Source code)
machine language, but they are highly detailed and
cryptic. So, programmers seldom write programs in LDD 101
Assembly language.
ADD 102
Advantages of Assembly languages:
• to make use of special hardware
• to make use of special machine-dependent instructions
• to write code that doesn‟t take up much space in primary memory
• to write code that performs a task very quickly.
In order to understand this program the programmer needs to know that
• LDD means load the value of the variable from memory into the accumulator
• ADD means add the value of another variable to the value stored in the
accumulator
• STO means store the value for accumulator into memory.

3) High Level Languages


High-level languages consist of familiar English words as result programmers can read,
write and understand programs easily.
It is a third generation of languages.
A language translator (compiler or interpreter) translates source code of High Level
Language into object code. That's why the program of High Level Language can be executed on
any machine.
High Level Code (Source code)

For Count=1 to 10
Print ''Allah''
Next Count
High-level languages are designed with programmers in mind; programming statements are easier
to understand than those written in a low-level language.
This means that programs written in a high-level language are easier to:
• read and understand as the language used is closer to human language
• write in a shorter time
• debug at the development stage
• maintain once in use.
Examples: Python, COBOL, Pascal, FORTRAN, GWBASIC, C++, JAVA, VB.Net.

Source Code:
''A program written in any language except the machine language is called Source Code.''
Programmers can write programs in Machine Language, Assembly Language and High
Level Languages like COBOL, PASCAL, and GWBASIC etc. The programs, written in Assembly
Language or any High Level Language are called Source Code.

Object Code:
''A program written in Machine Language is called Object Code.''
Computer can understand only machine language code. Language translators converts
source code of High Level Language into machine code, these converted codes are Object
Codes.
Language Translator:

''Language Translators are programs that convert or translate the instructions in Assembly
Language or High Level Language i.e. source code into instructions of machine language i.e.
object codes are called Language Translators.''
Computer can understand only machine language. Programs written in Assembly Language
and High Level Language are translated into Machine Language so as computer can understand
execute them.

Source Code Language Object Code


(Program in Translator (Program
Assembly or High (Assembler, converted in
Level Language) Compiler or Machine

Following are three types of language translators:


1 Assembler:-
''Assembler is a language translator that translates source program written in Assembly
Language into object code in machine language.''
Computer can understand only machine language. Assemblers translate programs written
in Assembly Language into Machine Language so as computer can understand execute them.

Assembly Machine Language


Assembler
Language Object Code
2 Interpreters:-
''An interpreter is a language translator that translates source program written in High Level
Language into object code in machine language during step by step execution of program.''
Computer can only understand instruction written in machine language. Interpreters
translate one by one instruction of High Level Language source code into object code of Machine
Language.
Interpreter translates one instruction which is executed before translation of next instruction.
The object code is not saved so the source code is interpreted every time before the execution.
Each high level language has its own language translator.

High Level Machine


Interpreter
Language Language

3 Compilers:-
''A compiler is a language translator that translates whole source program written in High
Level Language into object code in machine language before execution of program.''
Compilers translate all instructions before executions. The object code is saved as object
file, which is executable. Object files don't need compiler or language for execution.

High Level Machine Language


Language Compiler Object Code
Source Code (Executable file)
Compiler Interpreter Assembler
Translates a high-level language Executes a high-level language Translates a low-level language
program into machine code. program a statement at a time. program into machine code.

An executable file of machine No executable file of machine code is An executable file of machine
code is produced. produced. code is produced.
One high-level language One high-level language program One low-level language
statement can be translated statement may require several statement is usually translated
into several machine code machine code instructions to be into one machine code
instructions. executed. instruction.
Compiled programs are used Interpreted programs cannot be used Assembled programs can be
without the compiler. without the interpreter. used without the assembler.
A compiled program is usually An interpreter is often used when a An assembled program is
distributed for general use. program is being developed. usually distributed for general
use.

Tick (✔) to show whether each statement about interpreters is true or false.
Statement Assembler Compiler Interpreter
Translate a line of code at a time then execute it.
Stop executing the code when an error occurs.
Report all syntax errors at the same time in a report.
Will not run the program at all until all errors are corrected.
A report of all syntax errors is produced at the same time.
The program is translated one line at a time then executed.
The program is translated from high-level language into machine
code.
An executable file is produced.
The program will not run at all if an error is detected.
Translates low-level language to machine code
Integrated/Interactive Development Environment (IDE)
Most high-level programming languages offer the use of an IDE for program development. This
contains an editor with an interpreter and/or
compiler together with debugging tools, which
Code Editor
can improve the speed of program
development.
Auto
Translator
completion
Functions of IDE:
1. Code editor: IDE provides a text editor
to type and edit program codes.
2. Auto-completion: feature displays hints Error
Diagnostic:
IDE Auto
correction
(or a choice of keywords) and available Dubug

identifiers that might be appropriate at


the current insertion point of the
Run-time Pretty
program code. environment printing

3. Auto-correction: a feature that


identifies misspelled words and suggests correction.
4. Pretty printing is a feature of IDE that refers to the presentation of the program code typed into an
editor. For example, IDE automatically colour-codes keywords, built-in function, calls, comments,
strings, and the identifier in a function header. In addition, indentation is automatic.
5. Dynamic Syntax Checking is also offered by some source code editors. When a line has been typed,
some editors perform syntax checks and alert the programmer to errors.
6. Error diagnostics: a feature that identifies syntax errors, and helps in debugging.
7. Run-time environment: feature that provides environment where code and be run and tested.
8. Translator: a feature that converts source code into object code.
Means to avoid faults
To avoid faults subroutines and programs are tested. Modular programming techniques (to break
the problem down and make it easier to solve) are used. Good programming practice like
formatting, sensible variable names, comments etc. are also helpful in avoiding program fault. An
IDE is used during coding stage having features like parameter type-checking, auto-complete.
Some software development IDEs check the source code for syntax errors in real-time.
Locate and identify the different types of errors.
Errors in program can be classified as follows:
1. Syntax Error
2. Run-Time Error
3. Logic Error
Syntax error
Syntax error is an error in which a program statement does not follow the rules of the
programming language (grammar of programming language).
For example, a message to be printed if written without quotation marks, or space in variable
name.
Syntax error prevent an application from being successfully compiled, programs cannot be
executed.
Some software development IDEs check the source code for syntax errors in real-time, while
others only generate syntax errors when a program is compiled.
In most cases, the compiler or interpreter provides the location (or line number) of the syntax error,
making it easy for the programmer to find and fix the error.
Run-time Error
A runtime error occurs when a program is syntactically correct but contains an issue that is only
detected during program execution. These issues cannot be caught at compile-time.

Divide by zero, numeric overflow are examples of run-time error. Run-time error may be identified
by careful testing in an IDE. They are much more difficult to discover, as program appears to work
until a certain set of data causes a malfunction.
Logic Error
An error in the logic of program, program is executed but not work as it is intended to be. It causes
program to operate incorrectly, but not to terminate abnormally (or crash). A logic error produces
unintended or undesired output or other behaviour, although it may not immediately be recognized
as such. Because a program with a logic error is a valid program in the language, though it does
not behave as intended.

Often the only clue to the existence of logic errors is the production of wrong solutions, though
static analysis may sometimes spot them.
Why errors in a program are called BUG

The term "bug" was used in an account by computer pioneer Grace Hopper, who publicized the cause of a
malfunction in an early
electromechanical computer. A typical
version of the story is:

“In 1946, when Hopper was released


from active duty, she joined the
Harvard Faculty at the Computation
Laboratory where she continued her
work on the Mark II and Mark III.
Operators traced an error in the Mark
II to a moth trapped in a relay, coining
the term bug. This bug was carefully
removed and taped to the log book.
Stemming from the first bug, today we
call errors or glitches in a program.”
a bug. Courtesy Wikipedia

Revision Guide Check List

4.2 Types of programming language, translators and IDEs R A G

Explain what is meant by a high-level language and a low-level language, including the
1
advantages and disadvantages of each
Understand that assembly language is a form of low-level language that uses
2 mnemonics, and that an assembler is needed to translate an assembly language
program into machine code
Describe the operation of a compiler and an interpreter, including how high-level
3
language is translated by each and how errors are reported
4 Explain the advantages and disadvantages of a compiler and an interpreter
Explain the role of an IDE in writing program code and the common functions IDEs
5
provide
Topical Past Papers - SoW

0a 2023 Specimen Paper 1a

4 (d) The computer uses a bootstrap.


Tick one box to show the part of a computer of which the bootstrap is an example. [1]
A application software
B firmware
C hard disk drive
D MAC address
5 A programmer uses a high-level language to create a computer program.
(a) (i) Identify two advantages to the programmer of using a high-level language instead of a low-
level language.
1 ........................................................................................................................................
2 ................................................................................................................................... [2]
(ii) Suggest one disadvantage to the programmer of using a high-level language instead of a low-
level language.
...................................................................................................................................... [1]
(b) The programmer uses an integrated development environment (IDE) when creating the
computer program. State what is meant by an IDE.
...................................................................................................................................................
.............................................................................................................................................. [1]
0b Specimen Paper 1b
5 (a) Complete the statements about different types of programming language.
Use the terms from the list.
Some of the terms in the list will not be used. You should only use a term once.
Assembly denary executable file instruction storage hexadecimal style
high-level low-level machine code protocol source code syntax translator
The structure of language statements in a computer program is called the ......................................... .
A programming language that uses natural language statements is called a ................................... language.
When programs are written in this type of language they need a ...................................... to convert them
into ............................................. .
A programming language that is written using mnemonic codes is called an ....................................language.
This is an example of a ............................................. language. [6]
(b) A programmer often uses an integrated development environment (IDE) when writing a computer
program.

Give three common functions of an IDE.


Function 1 .................................................................................................................................
Function 2 .................................................................................................................................
Function 3 ............................................................................................................................................ [3]
1b fm23
2 A programmer has designed a three-dimensional (3D) interactive computer game. They are going to
develop a program for the game. The program needs to run efficiently, but it must also be developed as
soon as possible.
(a) Tick (✓) one box to identify whether the programmer should use a high-level language or a low-level
language to develop the program. Explain the reasons for your choice.
High-level language
Low-level language
Reasons for your choice ...........................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [4]
(b) If the programmer chooses a high-level language, they can use a compiler or an interpreter to translate
the high-level language into a low-level language.
Describe the operation of a compiler and of an interpreter.
Compiler ...................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
Interpreter .................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
................................................................................................................................................... [4]
11b March 2019 Paper 12
4 Darius is writing a computer program that allows binary values to be calculated.
Darius chooses to write the program in a high-level language rather than a low-level language.
(a) Explain why Darius chooses to write the program in a high-level language.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [2]

(b) Darius will use a translator to translate the program. He could use a compiler or an interpreter.
Five statements are given about compilers and interpreters.
Tick to show if the statement applies to a Compiler or an Interpreter. Statements may apply to
both. [5]
Statement Compiler Interpreter
A report of errors is produced at the end of translation.
The program is translated one line at a time.
The program is translated from high-level language into machine code.
An executable file is produced.
The program will not run at all if an error is detected.

12a June 2019 Paper 11


7 Annie writes a paragraph of text as an answer to an examination question about programming
languages. Using the list given, complete Annie‟s answer by inserting the correct six missing
terms. Not all terms will be used.
• Assembly • Converter • Denary • High-level language
• Hexadecimal • Machine Code • Source Code • Low-level language
• Syntax • Translator
The structure of language statements in a computer program is called the ............................
........................................ . A programming language that uses natural language statements is
called a.....................................................................................When programs are written in this type of
language they need a.................................................................................. to convert them into
....................................................................... . A programming language that is written using
mnemonic codes is called .................................................................................. language. This is an
example of a ....................................................................... . [6]
13a Nov 2019 Paper 11
6 Ishan is a member of a software community that develops computer games. He has
programmed a new feature for one of the community‟s existing games.
(a) Ishan compiles the program before he issues it to the community.
(i) Explain one benefit of Ishan compiling the program.
...........................................................................................................................................
..................................................................................................................................... [1]
(ii) Explain one drawback of Ishan compiling the program.
...........................................................................................................................................
..................................................................................................................................... [1]
13b Nov 2019 Paper 12
7 Gerald uses a keyboard to enter a website address into the address bar of his browser.
(a) Describe how Gerald‟s key presses on his keyboard are processed by the computer.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [4]
13c Nov 2019 Paper 13
2 A programmer uses a high-level language to write a computer program.
(a) Four statements are given about high-level programming languages.
Tick to show if each statement is True or False. [4]
Statement True False
High-level languages need to be translated into machine code to run on a
computer
High-level languages are written using mnemonic codes
High-level languages are specific to the computer‟s hardware
High-level languages are portable languages
(b) Tick to show which of the following is an example of a high-level language program. [1]
Example program Tick
1011100000
1100000000
0110111000
INP
STA ONE
INP
ADD ONE
a = input()
b = input()
if a == b: print("Correct")
7(b) Computer systems often use interrupts.
Five statements are given about interrupts. Tick to show if each statement is True or False. [5]
Statement True False
Interrupts can be hardware based or software based
Interrupts are handled by the operating system
Interrupts allow a computer to multitask
Interrupts work out which program to give priority to
Interrupts are vital to a computer and it cannot function without them

14a March 2020 Paper 12


4 Assemblers, compilers and interpreters are types of translators. Tick to show which statements
apply to each translator. Each statement may apply to more than one type of translator. [5]
Statement Assembler Compiler Interpreter
Translates low-level language to machine code
Translates high-level language to machine code
Produces error messages
Translates high-level language one line at a time
Produces an executable file
15a June 2020 Paper 11
8 Benny is a photographer and prints his photos using an inkjet printer.
(a) Benny is printing some photos and the paper gets jammed in the printer.
A signal is sent to alert the computer about the paper jam. State the name of this type of signal.
............................................................................................................................................. [1]
9 Programs can be written in a low-level language.
(a) Identify three features of a low-level language.
Feature 1 ..................................................................................................................................
Feature 2 ..................................................................................................................................
Feature 3 .................................................................................................................................................... [3]
(b) Give two examples of a low-level language.
Example 1 .................................................................................................................................
Example 2 ................................................................................................................................................... [2]
(c) Give one drawback of writing programs in a low-level language, instead of a high-level
language.
...................................................................................................................................................
............................................................................................................................................. [1]
15b June 2020 Paper 12
2 Both an interpreter and a compiler can be used when writing a program in a high-level language.
(a) Explain why a programmer would make use of both an interpreter and a compiler.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [4]
(b) Give three reasons why a programmer would choose to write a program in a high-level
language, instead of a low-level language.
Reason 1 ..................................................................................................................................
...................................................................................................................................................
Reason 2 ..................................................................................................................................
...................................................................................................................................................
Reason 3 ..................................................................................................................................
................................................................................................................................................... [3]
8 (c) An interrupt signal is sent from the printer to the computer.
(i) Give two examples of when a printer would generate an interrupt signal.
Example 1 .........................................................................................................................
Example 2 .......................................................................................................................................... [2]
(ii) Many devices send interrupt signals.
Identify the software in the computer that will receive and manage all interrupt signals.
..................................................................................................................................... [1]

Summer 2015 P12


9 (a) Five statements about interpreters and compilers are shown in the table below.
Study each statement.
Tick (✓) to show whether the statement refers to an interpreter or to a compiler.
Statement Interpreter Compiler
creates an executable file that runs directly on the computer
more likely to crash the computer since the machine code
produced runs directly on the processor
easier to debug since each line of code is analysed and
checked before being executed
slow speed of execution of program loops
it is more difficult to modify the executable code, since it is in
machine code format
(b) State why a compiler or an interpreter is needed when running a high-level program on a
computer.
............................................................................................................................................................
............................................................................................................................................................
.........................................................................................................[1]

(c) Give one benefit of writing a program in a high-level language.


............................................................................................................................................................
............................................................................................................................................................
........................................................................................................ [1]

(d) Give one benefit of writing a program in a low-level language.


............................................................................................................................................................
............................................................................................................................................................
...................................................................................................... [1]
(e) Study the following three sections of code.
A B C
1 0 1 0 1 1 0 1 LDA X FOR x ← 1 TO 10
1 1 0 0 1 1 1 0 INC X READ n
1 0 1 1 0 1 1 1 STA Y ENDFOR

Identify, using the letters A, B or C, which of the above codes is an example of assembly code,
high-level language code or machine code:
Assembly code ....................................................................................................................
High-level language code .................................................................................................
Machine code .............................................................................................................................. [2]

Summer 2016 P12


Complete the following by writing either compiler, interpreter or assembler. [3]
............................................ – translates source code into object code.
............................................ – translates low-level language into machine code.
............................................ – stops the execution of a program as soon as it encounters an error.
Winter 2016 P12
1 (a) Give two reasons why a programmer would choose to write code in a low-level language.
1 ................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
2 ................................................................................................................................................
...................................................................................................................................................
................................................................................................................................................... [2]
(b) Tick (✓) to show which statements refer to interpreters and which refer to compilers. [5]
Statements Interpreter Compiler
Translates the source code into machine code all at once
Produces an executable file in machine code
Executes a high-level language program one instruction at a time
Once translated, the translator does not need to be present for the
program to run
An executable file is produced
March 2017 India
11 Three programmers are working on different projects:
• Alice is developing a program written in a low-level language
• Akbar is developing a program written in a high-level language
• Alex is preparing a program written in a high-level language for sale
State, with reasons, which type of translator each programmer should use. Each programmer
should be using a different type of translator.
Alice
............................................................................................................................................................
............................................................................................................................................................
...................................................................................................................................................
Akbar
............................................................................................................................................................
............................................................................................................................................................
................................................................................................................................................
Alex
............................................................................................................................................................
............................................................................................................................................................
............................................................................................................................................. [6]

You might also like