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

Chapter 4 (part 2 PL)

The document discusses programming languages, categorizing them into high-level and low-level languages, with high-level languages being closer to human language and easier to debug, while low-level languages offer more control and efficiency. It explains the role of translators such as compilers, interpreters, and assemblers in converting high-level code to machine code, highlighting their advantages and disadvantages. Additionally, it introduces Integrated Development Environments (IDEs) that assist programmers with features like code editing, translation, debugging, and error diagnostics.

Uploaded by

chawyadanarsan20
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Chapter 4 (part 2 PL)

The document discusses programming languages, categorizing them into high-level and low-level languages, with high-level languages being closer to human language and easier to debug, while low-level languages offer more control and efficiency. It explains the role of translators such as compilers, interpreters, and assemblers in converting high-level code to machine code, highlighting their advantages and disadvantages. Additionally, it introduces Integrated Development Environments (IDEs) that assist programmers with features like code editing, translation, debugging, and error diagnostics.

Uploaded by

chawyadanarsan20
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 22

Chapter (4)

High-level and low-level languages


What is Program.
Program
 is a set of instruction that tell computer what to do and how to do
a specific task.
 enables a single computer to perform many different types of
task.

Programming Languages
 A set of words and symbols used to write a program
 is a computer language that is used by programmers
(developers) to communicate with computers.
 High Level Languages
 Low Level Languages
High Level Language
 are written in a form that is close to our human(natural) language, enabling to
programmer to just focus on the problem being solved.
 require no knowledge of the hardware and instruction set of the computer that will
use the program.
 are portable and can be used on different types of computer
 Examples include: C++, Java, Pascal, Python, Visual Basic.

Sum := FirstNumber + SecondNumber

Advantages
 Closer to English Language/ human Language so that
easier to read/ write/ understand
 Easier to debug
 Less likely to make errors
 One lines of code can carry out multiple command
 Portable language
Low level Language
 are used to write programs that relate to the specific architecture and hardware of
a particular type of computer.
 are closer to the native language of a computer (binary) making them harder for
programmers to understand.
 Examples of low level language:
 Assembly Language
 Machine Code
Assembly Language
 Few programmers write programs in an assembly language.
 is easy distinguishable from a high level language as it
contains few recognizable human words but plenty mnemonic
code 4 First

Acc
LDA First
ADD Second 4 9 5 Second
STO Sum

9 Sum
LDA means load the value of the variable into the accumulator
ADD means add the value of another variable to the value stored in the accumulator
STO means replace the value of the variable by the value stored in the accumulator.
Assembly Language
Advantages
 Can make use of special hardware or special machine-dependent instructions (e.g.
on the specific chip)
 Translated program requires less memory
 Write code that can be executed faster
 Total control over the code
 Can work directly on memory locations
Limitation
 A very limited range of instructions is available
 Debugging is very difficult
Machine Code
 Programmers rarely write in machine code (binary) as it is difficult to understand
and it can be complicated to manage data manipulation and storage.
Advantages Disadvantages
High Level Independent of the type of computer Programs can be larger
Language being used (portable) Programs can take longer to
Easier to read, write and understand execute
programs Programs may not be able to use of
Quicker to write program special hardware
Programs are easier and quicker to
debug
Easier to maintain program in use
Low Level Can make use of special hardware It takes a longer time to write and
Language Includes special machine-independent debug programs
instructions Programs are more difficult to
Can write code that doesn’t take up understand
much space in primary memory
Can write code that performs a task
very quickly
Translators

Why translator is needed?


 The computer can only understand machine code low-level language
 But programmer used to write program in high level language.
 Thus, program (source code) need to be translated into machine code using
translator.
What is translator?
 Translator is a software that convert the source code into machine code (object
code).
 There are three type of translator
 Compiler
 Interpreter
 Assembler
Compilers
 is a program that translates high level language program (source code) into machine code, often
object code and saved as executable file to be executed later
 Translates (the source code) all in one go/all at once and produce an executable file of machine
code.
 Once compiled ,machine code can then be directly used by the computer.
 Compiled programs are used without the compiler.
 Error report produced once entire program is compiled. (error may cause program to crash)
 One high-level language statement may be several lines of machine code when compiled.

Error report

Source code Object code (.exe file)


Compiler
00100000
Sum = 1+2 10000100
Sum = 1# 2 11110000
Advantages and Disadvantages of Compiler

Advantages Disadvantages
 The compiled program will run without  The source code must be re-compiled
compiler. To run it, the compiler don’t every time the programmer changes the
need to install on user’s computer. program.
 Compiled programs run quickly, since  Debugging a compiled program is
they have already been translated. relatively difficult as all the errors found
 are reported together.
Compilers optimize code. Optimized
code can run quicker and take up less  It take longer time to test and debug
memory space. during development
 an executable file cannot be easily
modified which makes secure and
privacy.
Interpreter
 Is a program that translate a high-level language program into object code ,often
machine code and execute one statement(lines) at a time from.
 Translates (the source code) line by line/statement by statement
 No executable file of machine code is produced.
 Interpreted programs cannot be used without the interpreter.
 Error message produced immediately (and program stops at that point)
 One high-level language statement may be several lines of machine code
when compiled.

Source code result 3


Intepreter
Error report
Sum = 1+2
0010000
run
Sum = 1# 2 0
1000010
0
Advantages and Disadvantages of Interpreter

Advantages Disadvantages
  Interpreted programs cannot be used
Easier and quicker to debug and test
programs during development. without the interpreter.
  Interpreted programs run slowly as the
Errors can be quickly spotted - once an
error is found, the program stops running processor has to wait for each instruction
and the programmer is notified at which to be translated before it can be executed.
part of the program has failed.  Interpreters do not produce an executable
 Interpreter is easier to use, especially for file that can be distributed. As a result, the
beginner. source code program has to be supplied,
and this could be modified without
permission.
 Interpreters do not optimize code - the
translated code is executed as it is.
Assembler
 are used to translate a program written in assembly language into a machine code
(object code) file.
 An executable file of machine code is produced.
 Assembled programs can be used without the assembler.
 One low-level language statement is usually translated into one machine code
instruction.
 An assembled programs are used without assembler.
 An assembled program is usually distributed for general use.
(b) Write down the other three of the functions of a typical operating system
1 …………………………………………………………………………
2 …………………………………………………………………………
3 …………………………………………………………………… [3]
2.The programmer uses the high-level language or low-level language to write a program.
(a) State three benefits of writing a program in a high-level programming languages.
[3]
1 ………………………………………………………………………
2 …………………………………………………………………………
3 ……………………………………………………………………………
(b) Explain why a programmer would not choose to write a program in a low-level programming language.
[2]
……………………………………………………………………………
……………………………………………………………………………
The compilers and interpreters are types of translators.
Tick (√) to show which statements apply to each translator. [5]

Statement Compilers Interpreters


Translate high level language one line at time
Produce executable file
Report all error messages together
Optimize the source code
Once the source program is translated, the
translated will not run without the translator
 Chapter ( 1 (hexa binary ))
 Chapter (2 – Data transmission)
 Chapter (10 – Logic gate)
 Chapter (4 – Software )
Integrated Development Environment (IDE)
 An Integrated Development Environment (IDE) is used by programmers to aid the writing and
development of programs.
 There are many different IDEs available; some just support one programming language,
others can be used for several different programming languages.
 Example : PyCharm (for Python), Visual Studio (for Visual Basic) or eclipse (for Java).
 IDEs usually have these features:
 code editors
 a translator
 a runtime environment with a debugger
 error diagnostics and auto correction
 auto-completion
 an auto-documenter and prettyprinting.
Integrated Development Environment (IDE)
 Code editor : allows a program to be written and edited without the need to use a
separate text editor.
 Translator : provide a translator ( compiler or interpreter) to enable the program to be
executed
 A runtime environment with debugger : a program that runs the program under
development and allows the programmer to step through the program a line at time
 Error diagnostics and auto-correction :finds possible errors as the program code is
being typed, alerts the programmer at the time and provides a suggested correction
 Auto completion : Code editors can offer context-sensitive prompts with text completion
for variable names and reserved words.
 Auto-documenter and prettyprinting: IDEs can provide an auto-documenter to explain
the function and purpose of programming code.

You might also like