You are on page 1of 39

Programming languages A set of words symbols and codes used to write a program is called programming language Two types

of programming languages Low level languages High level languages

Engr:Sajida Introduction to Computing

Low level languages Near to computer hardware and far from human languages Computer can understand these languages easily Two types of low levels languages Machine languages Assembly languages

Engr:Sajida Introduction to Computing

Machine language The first-generation programming language, or 1GL, is machine code It is the only language a microprocessor can understand directly. Currently, programmers almost never write programs directly in machine code Instructions are written in binary form Program written in machine language is machine dependent Every computer has its own machine language
Engr:Sajida Introduction to Computing

Assembly language . Assembly languages have the same structure and set of commands as machine languages, these commands are names or symbols instead of numbers. Each type of CPU has its own machine language and assembly language An assembly language program written for one type of CPU won't run on another. also called symbolic language Mostly used for writing system software it is called second generation language or 2GL
Engr:Sajida Introduction to Computing

3GL 2GL

1GL

Engr:Sajida Introduction to Computing

High level languages These languages are close to human languages Instructions of these languages are written in English like words These are not machine dependent languages The main advantage of high-level languages over low-level is that they are easier to read, write, and maintain. Ultimately, programs written in a high-level language must be translated into machine language by a compiler or interpreter.
Engr:Sajida Introduction to Computing

The first high-level programming languages were designed in the 1950s. Now there are dozens of different languages including BASIC,COBOL, C, C++,C# FORTRAN, Pascal

Engr:Sajida Introduction to Computing

BASIC ( Beginner's All-purpose Symbolic Instruction Code) developed by Dennis Ritchie at AT & T Bell Laboratories in the mid 1960s BASIC is one of the earliest and simplest high level programming languages. During the 1970s, it was the principal programming language taught to students, and continues to be a popular choice among educators. BASIC is used for a wide variety of business application There is an ANSI standard for the BASIC languages, but most versions of BASIC include many extensions Visual Basic, for example, adds many object oriented features to the standard BASIC.

Engr:Sajida Introduction to Computing

COBOL Acronym for common business oriented language. Developed in the late 1950s and early 1960s, COBOL is the second-oldest high level language . It is particularly popular for business applications that run on large computers

Engr:Sajida Introduction to Computing

FORTRON Acronym for formula translator, FORTRAN is the oldest high level programming language. Designed by John Backus for IBM in the late 1950s, it is still popular today, particularly for scientific applications that require extensive mathematical computations

Engr:Sajida Introduction to Computing

C++ A high level programming language developed by Bjarne Stroustrup at Bell Labs. C++ adds object oriented features to its predecessor, C C++ is one of the most popular programming languages for graphical applications, such as those that run in windows and Macintosh environments.

Engr:Sajida Introduction to Computing

High level languages are further divided into three categories Procedural languages Object - oriented languages Non- procedural languages

Engr:Sajida Introduction to Computing

C# Pronounced "see-sharp." A hybrid of C and C++ C# is an object oriented programming language

Engr:Sajida Introduction to Computing

Procedural languages In these languages program is a predefined set of instructions computer executes these instructions in the same sequence in which the instructions are written each instruction in this language tell the computer what to do and how to do

Engr:Sajida Introduction to Computing

Most popular languages are FORTRON BASIC COBOL C PASCAL

Engr:Sajida Introduction to Computing

Object Oriented Programming Program is written on the basis of objects An object is a collection of data and functions Popular langauges are C++ java

Engr:Sajida Introduction to Computing

Non- procedural languages Non procedural languages are also called 4GL User only tell the computer what to do not how to do 4GL normally used in database application and report generation SQL (structured query language) RPG (report program generator )

Engr:Sajida Introduction to Computing

Difference between procedural and non procedural languages Difference between low level and high level languages

Engr:Sajida Introduction to Computing

Types of codes Source code Program instructions in their original form. The word source differentiates codes from various other forms that it can have for example ,object code and executable code. Initially, a programmer writes a program in a particular programming languages This form of the program is called the source program, or more generically, source code
Engr:Sajida Introduction to Computing

Object code An object code is a program that is translated by a language processor It is also called machine code compiler produces an intermediary form called object code. The final step in producing an executable program is to transform the object code into machine language, if it is not already in this form. This can be done by a number of different types of programs, called assemblers, binders, linkers, and loaders.
Engr:Sajida Introduction to Computing

Language processors A software or program that converts program written in high level languages or assembly language into machine language every computer language has its own translators Compilers Interpreters Assemblers

Engr:Sajida Introduction to Computing

Compiler A program that translates source code into object code The compiler derives its name from the way it works, looking at the entire piece of source code and collecting and reorganizing the instructions A compiler can translate the program of only that language for which it is written C compiler can translate only those programs that are written in the C language

Engr:Sajida Introduction to Computing

Interpreter An interpreter is program that converts one statement of a program at one time It executes this statement before translating the next statement of the source program The advantage of an interpreter, is that it does not need to go through the compilation stage during which machine instructions are generated. This process can be time-consuming if the program is long. The interpreter, on the other hand, can immediately execute high-level programs. For this reason, interpreters are sometimes used during the development of a program
Engr:Sajida Introduction to Computing

Assembler An assembler is a program that translates the instructions of assembly language into machine language

Engr:Sajida Introduction to Computing

link editor
Also called link editor and binder, A linker is a program that combines object modules to form an executable program. Many programming languages allow you to write different pieces of code, called modules, separately. This simplifies the programming task because you can break a large program into small, more manageable pieces. Eventually, though, you need to put all the modules together. This is the job of the linker.

Engr:Sajida Introduction to Computing

Loader An operating system utility that copies programs from a storage device to main memory, where they can be executed. Most loaders are transparent you cannot directly execute them, but the operating system uses them when necessary. Utility A program that performs a very specific task, usually related to managing system resources. operating systems contain a number of utilities for managing disk drives printers and other devices
Engr:Sajida Introduction to Computing

Programming techniques Structured programming Object oriented programming

Engr:Sajida Introduction to Computing

Structured programming A technique in which program is divided in small units called modules or sub program Each module consists of different instructions to perform a particular task This module is executed when main program calls it Structured programming can be seen as a subset or sub discipline of procedural programming It is most famous for removing or reducing reliance on the GO TO statement
Engr:Sajida Introduction to Computing

GOTO is a statement found in many computer programming languages It is a combination of the English words go and to. When executed it causes an unconditional transfer of control (a "jump") to another statement. The jumped-to statement is specified using some kind of label, which may be an identifier or a line number depending on the language. At the machine code level a goto is a form of branch or jump statement.

Engr:Sajida Introduction to Computing

Structured programming is also called modular programming when main program calls a module the control moves to call module temporarily the control moves back to the main program after executing the instructions of the module

Engr:Sajida Introduction to Computing

Types of instruction used in structured programming Sequential structure Conditional structure Iterative structure

Engr:Sajida Introduction to Computing

Sequential structure Statements are executed in the same sequence in which they are written in program
Statement 1

Statement 2
Statement 3

Statement 4

Engr:Sajida Introduction to Computing

Conditional structure A selection structure selects statement or set of statements to execute on the basis of condition if condition is true than statement is executed other wise it is ignored
Condition Tor F statement2

statement1

Engr:Sajida Introduction to Computing

Iterative structure
A repetition structure executes a statement or set of statement repeatedly It is called loop or iteration structure Loop is used for two purposes Loop is used to execute a statement or no of statement for a specified number of time F Condition To use a sequence of values Tor F
T statement

Engr:Sajida Introduction to Computing

Function call Function call is type of statement that moves the control to another block of code Control returns back after executing all the statements in the block
statement
Function call statement Function Statements

return

Engr:Sajida Introduction to Computing

Object oriented programming Program written on the basis of objects Object is a collection of data and functions Every thing in a real world is considered as a object

Engr:Sajida Introduction to Computing

Features of OOP Objects provides the facility of programming based on objects object is an entity that consists of data and functions Classes are design to create objects OOP provides facility to design classes to create different objects Defines the characteristics of a thing (object), including the thing's characteristics (its attributes, fields or properties ) and the thing's behaviors (the things it can do, or methods, operations or features). One might say that a class is a factory that describes the nature of something
Engr:Sajida Introduction to Computing

Inheritance A technique that allows a programmer to use code of existing program to create the new class Subclasses are more specialized versions of a class, which inherit attributes and behaviors from their parent classes, and can introduce their own

Engr:Sajida Introduction to Computing

Encapsulation OOP allows the programmer to hide the data from other user through encapsulation Polymorphism polymorphism in object oriented programming is the ability of objects belonging to different data types to respond to method calls of methods of the same name, each one according to an appropriate type and specific behavior

Engr:Sajida Introduction to Computing

You might also like