0% found this document useful (0 votes)
3 views17 pages

Understanding Programming Languages

The document provides an overview of programming languages, detailing their types, including machine language, assembly language, and high-level languages, along with their characteristics and advantages. It explains the roles of interpreters and compilers in translating high-level code into machine language, as well as the concept of debugging. Additionally, it covers the basics of data representation in computers, including bits and bytes.

Uploaded by

kumatanaamahle26
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)
3 views17 pages

Understanding Programming Languages

The document provides an overview of programming languages, detailing their types, including machine language, assembly language, and high-level languages, along with their characteristics and advantages. It explains the roles of interpreters and compilers in translating high-level code into machine language, as well as the concept of debugging. Additionally, it covers the basics of data representation in computers, including bits and bytes.

Uploaded by

kumatanaamahle26
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

Data

Representation:
Programming
Languages

Lecturer : Manoj Philip


Email : Mphilip@[Link]
Objectives

• Understand what is a programming


language
• Understand the different types of
programming languages
• Understand the Interpreter, Compiler and
Debug
• Understand bits and bytes
What Is a Computer Language?
• A microprocessor is designed to “understand” a set
of commands called an “instruction set”
• All instructions must be provided to the CPU in its
native language, called machine language.
• All data transmission, manipulation, storage, and
retrieval is done by the machine using electrical
pulses representing sequences of binary digits.
• If eight-digit binary codes are used, there are 256
numbered instructions from 00000000 to 11111111.
The Computer Level Hierarchy
Languages of Computers
• Machine Language
– Programs consist of machine instructions
– Directly executable without preprocessing
– Direct manipulation of machine registers
– Efficient in view of machine resource utilization
– Difficult to program
• Assembly language
– Improved version of machine language with emphasis on user-
friendliness
– Symbolic machine language (symbols for operations and addresses)
– Assembler is needed to translate into a machine language program
• High-Level Language
– Programs consist of statements, each of which can be translated
into several machine language instructions
– Need a compiler to translate into a machine language program
– Relatively easy to program compare to ML or AL
– Hardware resource utilization may be inefficient
Machine Language
• Instructions for adding two numbers would
consist of a sequence of these eight-digit codes
from 00000000 to 11111111
• Instructions written in this form are referred to as
machine language
• It is the native language that the CPU “speaks” and
“understands”
• It is possible to write an entire program in
machine language. However, this is very time
consuming and difficult to read and understand
Programming Languages
• Fortunately, special languages have been developed
that are more easily understood (than machine
language)
• These special languages are called programming
languages
• These languages provide a way to write computer
programs that are understood by both computers and
people
• Programming languages have their own vocabulary and
rules of usage
• Some languages are very technical, while others are
similar to English
Low Level Languages
• Machine Language and Assembly Language
are both called low-level languages
• In a low-level language, it is necessary for
the programmer to know the instruction
set of the CPU in order to program the
computer
• Each instruction in a low-level language
corresponds to one or only a few
microprocessor instructions
High Level Languages

• A high-level language is any programming


language that uses words and symbols to
make it relatively easy to read and write a
computer program
• In a high-level language, instructions do not
necessarily correspond one-to-one with the
instruction set of the CPU
• One command in a high-level language may
correspond to many microprocessor
instructions
High Level Languages (contd..)

• Many high-level languages have been


developed. These include:
– FORTRAN, COBOL, BASIC, Logo, Pascal, C, C++,
Java, and others
• These languages simplify even further the
terminology and symbolism necessary for
directing the machine to perform various
manipulations of data
Advantages: High Level Languages &
Low Level Languages
HIGH LEVEL LANGUAGES LOW LEVEL LANGUAGES

1. Reduce the number of 1. Instructions can be written to


instructions that must be written enable the computer to do
2. Allow programs to be written in a anything that the hardware will
shorter amount of time than a follow.
low-level language would take 2. Require less memory
3. Reduce the number of errors that 3. Run more quickly
are made, because… The
instructions are easier to read.
4. Are more portable (the programs
are easier to move among
computers with different
microprocessors)
Interpreters and Compilers

• Programmers writing in a high-level language enter


the program’s instructions into a text editor
• The files saved in this format are called text files
• A program written in a high-level language is called
Source Code
• The programs are translated into machine language
by interpreters or compilers
• The resulting machine language code is known as
Object Code
Interpreters
• An interpreter is a program that translates the
source code of a high-level language into
machine language
• Each instruction is interpreted from the
programming language as needed (line by line
of code)
• Every time the program is run, the interpreter
must translate each instruction again
• In order to “run” the program, the interpreter
must be loaded into the computer’s memory
Compilers
• A compiler is another program that translates a high-
level language into machine language.
• A compiler makes the translation once so that the
source code does not have to be translated each time
the program is run.
– The source code is translated into a file called an object file.
– A program called a linker is used to create an executable
program.
– Most modern compilers let you compile and link in a single
operation, and have an “IDE” (Integrated Development
Environment) to enter text, debug, compile, link, and run
programs.
Debug

• Bug: An error in coding or logic that causes


a program to malfunction or to produce
incorrect results.
• Debug: To detect, locate, and correct
logical or syntactical errors in a program.
Bits & Bytes
• A "bit" is atomic: the smallest unit of storage
• A bit stores just a 0 or 1
• "In the computer it's all 0's and 1's" ... bits
• Anything with two separate states can store 1
bit
• In a chip: electric charge = 0/1
• In a hard drive: spots of North/South
magnetism = 0/1
• A bit is too small to be much use
• Group 8 bits together to make 1 byte
Bits & Bytes (Cont….)
• A bit is a binary digit which is always 0 or 1
• 8 bits form 1 byte
• The largest number that can be stored in 1 byte is 111111112 =
28- 1 = 25510
• If we have one byte of storage available, this can be used to
hold positive numbers from 0 to 255 decimal
• If two bytes of storage are available, this is 16 bits, and we can
store numbers from 0 up to 216 - 1 = 6553510
• A six-bit register (i.e. storage location) can hold 26 possible
values, which might be the numbers from 0 up to 26 – 1 = 63.
• Exercise:
– What is the largest number that can be stored in a 4-byte
register?

You might also like