Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
235 views

Introduction To Programming

The document discusses different generations of programming languages and language translators. It describes the five generations of programming languages from first to fifth generation. First generation languages used binary machine code. Second generation included assembly languages which were easier for humans. Third generation introduced high-level languages like C++ and Java which were translated into machine code. Fourth generation aimed to be more natural language-like while fifth generation uses visual and voice interfaces. The document also defines assemblers as translating assembly code into machine instructions and compilers as translating entire high-level programs into machine code at once versus interpreters which translate programs line-by-line.

Uploaded by

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

Introduction To Programming

The document discusses different generations of programming languages and language translators. It describes the five generations of programming languages from first to fifth generation. First generation languages used binary machine code. Second generation included assembly languages which were easier for humans. Third generation introduced high-level languages like C++ and Java which were translated into machine code. Fourth generation aimed to be more natural language-like while fifth generation uses visual and voice interfaces. The document also defines assemblers as translating assembly code into machine instructions and compilers as translating entire high-level programs into machine code at once versus interpreters which translate programs line-by-line.

Uploaded by

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

INTRODUCTION TO

PROGRAMMING
Introduction to Programming
(Definition of Computer Program )

 A computer program is a collection of instructions that performs a specific task when executed
by a computer.
 A computer requires programs to function, and typically executes the program's instructions in
a central processing unit
 A computer program is usually written by a computer programmer in a programming language.
 From the program in its human-readable form of source code, a compiler can derive machine
code—a form consisting of instructions that the computer can directly execute. Alternatively, a
computer program may be executed with the aid of an interpreter.
 Programming language is a syntax, grammar, and symbols or words used to give instructions to
a computer
Generation of Programming Language
Generation of Programming Language
First Generation of Programming Language (1GL)

 The first generation of codes used to program a


computer, was called machine language or machine
code, it is the only language a computer really
understands, a sequence of 0s and 1s that the
computer's controls interprets as instructions,
electrically.
First Generation of Programming Language (1GL)

Features / Characteristics / Description


 Lowest level of programming language
 First programming language
 Use machine code, binary digits (bits) 0 and 1.
 The symbol 0 stands for the absence and the 1 stands for
the presence of an electric pulse
First Generation of Programming Language (1GL)

Advantages / benefit

 Machine language makes fast and efficient use of


the computer

 Itrequires no translator to translate the code. It is


directly understood by the computer
First Generation of Programming Language (1GL)

Disadvantages / Weaknesses

 All operation codes have to be remembered


 All memory addresses have to be remembered
 Code is difficult to edit and update
 Code cannot be ported to other systems and has to be rewritten
 It is hard to amend or find errors in a program written in the
machine language
Second Generation of Programming Language (2GL)

The second generation of code was called


assembly language, assembly language
turns the sequences of 0s and 1s into
human words like 'add'. Assembly language
is always translated back into machine code
by programs called assemblers.
Second Generation of Programming Language (2GL)

Features / Characteristics / Description

 Lowest level of programming language


 These alphanumeric symbols are known as
mnemonic codes
 The assembly language is converted to machine
codes by a language translator and then they are
executed by the computer.
Second Generation of Programming Language (2GL)

Advantages / Benefit

 Assembly language is easier to understand and use


as compared to machine language
 Code can be fast and efficient
 It is easy to locate and correct errors
 It is easily modified
Second Generation of Programming Language (2GL)

Disadvantages / Weaknesses

 Like machine language, it is also machine dependent /


specific
 Since it is machine dependent, the programmer also needs
to understand the hardware
High Level Language

 The third generation to fifth generation of code, was called high


level language or HLL, which has human sounding words and
syntax (like words in a sentence).
 In order for the computer to understand any HLL, a compiler
translates the high level language into either assembly language
or machine code.
 All software programming languages need to be eventually
translated into machine code for a computer to use the
instructions they contain.
Third Generation of Programming Language (3GL)

Features / Characteristics / Description


 "High-level" programming language
 Procedural language uses a series of English-like words, that are closer
to human language, to write instructions
 Procedural languages, because the program instructions comprise lists
of steps, procedures, that tell the computer not only what to do but how
to do it
 A language translator is required to convert a high-level language
program into machine language
 Two types of language translators: compilers and interpreters
 Example of programming language : C | C++ | Java | PASCAL
FORTRAN | BASIC | COBOL
Third Generation of Programming Language (3GL)

Advantages / Benefit
 To relieve the programmer of the detailed and tedious task of writing
programs in machine language and assembly languages
 To provide programs that can be used on more than one type of
machine with very few changes
 To allow the programmer more time to focus on understanding the
user’s needs and designing the software required meeting those
needs
 The programmer spends less time developing software with a high-
level language than with assembly or machine language because
fewer instructions have to be created
Third Generation of Programming Language (3GL)

Disadvantages / Weaknesses

 A high-level
language has to be translated into the
machine language by a translator, which takes up time
 The object code generated by a translator might be
inefficient compared to an equivalent assembly
language program
Fourth Generation of Programming Language (4GL)

Features / Characteristics / Description


 Fourth-generation languages attempt to make communicating with computers
as much like the processes of thinking and talking to other people as possible.
 The problem is that the computer still only understands zeros and ones, so a
compiler and interpreter must still convert the source code into the machine
code that the computer can understand.
 Fourth-generation languages typically consist of English-like words and phrases.
 Many fourth-generation languages use Structured Query Language (SQL) as the
basis for operations.
 SQL was developed at IBM to develop information stored in relational databases
Fourth Generation of Programming Language (4GL)

Advantages / Benefit

 Simplified the programming process


 Use nonprocedural languages that encourage users and
programmers to specify the results they want, while the
computers determine the sequence of instructions that will
accomplish those results
 Use natural languages that impose no rigid grammatical rules
Fourth Generation of Programming Language (4GL)

Disadvantages / Weaknesses

 Less flexible that other languages


 Programs written in 4GLs are generally far less
efficient during program execution that programs in
high-level languages. Therefore, their use is limited
to projects that do not call for such efficiency.
Fifth Generation of Programming Language (5GL)
Fifth Generation of Programming Language (5GL)

Features / Characteristics / Description


 The fifth-generation programming language or visual programming
language is also known as natural language
 Provides a visual or graphical interface, called a visual programming
environment, for creating source codes
 Fifth generation programming allows people to interact with computers
without needing any specialized knowledge
 People can talk to computers and the voice recognition systems can
convert spoken sounds into written words
 Prolog and Mercury are the best-known fifth-generation languages
 PROLOG, an artificial intelligence language that applies rules to data to
arrive at solutions
Fifth Generation of Programming Language (5GL)

Advantages / Benefit
 Logic based languages are able to represent the real
world more accurately
 Prolog is able to derive new rules from the existing rules
contained within the knowledge base
Fifth Generation of Programming Language (5GL)

Disadvantages / Weaknesses
 It can be very difficult to design a database that accurately
represents relationships
 Prolog is not best suited to solving complex arithmetical
computations
 Prolog programs are not best suited to the current PC
architecture (sequential execution) and are best optimised on
parallel architectures (fifth generation computers)
SUMMARY GENERATION PROGRAMMING LANGUAGE
LANGUAGE TRANSLATORS
TRANSLATORS
ASSEMBLER

 An assembler is a program that takes basic


computer instructions and converts them
into a pattern of bits that the computer's
processor can use to perform its basic
operations.
 Some people call these instructions
assembler language and others use the
term assembly language.
COMPILER

 It is a program which translates a high-level


language program into a machine language
program.
 A compiler is more intelligent than an assembler.
 It checks all kinds of limits, ranges, errors etc.
 But its program run time is more and occupies a
larger part of the memory.
 It has slow speed. Because a compiler goes
through the entire program and then translates
the entire program into machine codes.
COMPILER
INTERPRETER

 An interpreter is a program which translates statements of a


program into machine code.
 It translates only one statement of the program at a time.
 It reads only one statement of program, translates it and executes it.
 Then it reads the next statement of the program again translates it
and executes it.
 In this way it proceeds further till all the statements are translated
and executed
COMPILER AND INTERPRETER

 On the other hand, a compiler goes through the entire program and then translates the
entire program into machine codes.
 A compiler is 5 to 25 times faster than an interpreter.
 By the compiler, the machine codes are saved permanently for future reference.
 On the other hand, the machine codes produced by interpreter are not saved.
 An interpreter is a small program as compared to compiler.
 It occupies less memory space, so it can be used in a smaller system which has limited
memory space.
 They’re portable, which means they can run on different operating systems and platforms
COMPILER VS INTERPRETER
COMPILER VS INTERPRETER
5 Generations of Computer Program

CHERISTERISTIC
S

Advantages/
Name Level Translator Example
Disadvantages

• Machine Language • Low/high • Assembler • BASIC


• Assembly • Machine dependent • Compiler • FORTRAN
• 3rd Generation • Interpreters • C++
• 4GL • Java
• Natural • SQL
EXERCISES 1
EXERCISES 2
EXERCISES 3
EXERCISES ANSWER

1. The fourth generation languages are easier to use than the third generation languages.
a) State two examples of the fourth generation languages.[2]
 SQL, Prolog [1 mark each]
b) Describe two characteristics of the fourth generation languages.[4]
 used GUI(Graphical User Interface) that enable the user and the computer to communicate with
each other in the easier way.
 used to generate user specific report so that specific information can be generates to a specific user.
c) State the two similarities between the third generation languages and the fourth generation languages.
[1]
 The language is easy to understand.
 The language is easy to write.
ANSWER - EXERSISES 2

1. Programming languages (Topic 1)


a. Computer program is a set of instruction telling the computer what to do.
Computer program is written by a programmer by using a programming
language. [2]
b. Two differences between machine language and natural language. [2]
i. Machine language is hard to program compare to natural language. [1]
ii.Machine language need a translator while natural language doesn’t need
one.[1]
ANSWER - EXERSISES 2

c. Function of a compiler is to translate source code from a high-level programming language to a lower
level language into object code or machine code to create an executable program. [2]

d. Two characteristic of C programming language.[2]

i. C is a General Purpose Programming Language This means C can be used to write a variety of
applications. It is often referred to as a “system programming language.”

ii. C is a middle level language, which means it combines the features of high level language with the
functionality of an assembly language.

iii. C is a structured programming language, which means as a programmer, you are required to divide a
problem into a several different modules or functions.
ANSWER - EXERSISES 2

iv. C is renowned for its simplicity and is easy to use because of its structured approach. It has a vast
collection of keywords, operators, built-in functions and data types which make it efficient and powerful.

v. C is portable, which means a C program runs in different environments. C compilers are available for all
operating systems and hardware platforms. Additionally, you can easily write code on one system and
port it to another.

vi. C is popular not just because it can be used as a standalone programming language, but also as it can be
used as an interface to other more visual languages.

vii. C is a very flexible language; it is convenient and portable, like a high level language and flexible like a
low level language. It can be interfaced with other programming languages.

viii. C is super fast. The compilation and execution of programs is much faster on C than with most other
languages.
ANSWER - EXERSISES 3

You might also like