Programming Paradigm & Languages

27
Lecture 8 Programming Paradigm & Languages Lecturer: Sumaira Hussain S.M.I UNiversity

Transcript of Programming Paradigm & Languages

Page 1: Programming Paradigm & Languages

Lecture 8

Programming Paradigm & Languages

Lecturer: Sumaira Hussain

S.M.I UNiversity

Page 2: Programming Paradigm & Languages

Programming Languages

The process of telling the computer what to do Also known as coding

Page 3: Programming Paradigm & Languages

Batch ProgramsThese are typically started from a shell (or automatically via a

scheduler) and tend to follow a pattern of: –Initialize internal data –Read input data –Process that data –Print or store results

Key feature: No user interaction with the computer while the program is running

Examples?PC are a printing request or an analysis of a Web site log.

Page 4: Programming Paradigm & Languages

Event-Driven Programs

Examples? GUIs, microwave, camera

The system sends events to the program and the program responds to these as they arrive.

Page 5: Programming Paradigm & Languages

Event-Driven Programs

Events can include things a user does -like clicking the mouse -or things that the system itself does -like updating the clock.

These programs generally work as follows: –Initialize the internal data –Wait for events to arrive–Identify an incoming event and react

accordingly

Page 6: Programming Paradigm & Languages

Programming Languages

• Machine Language Assembly Language (1956-63)• LISP (1956)• Fortran (1957)• COBOL (1959)• PL/1(1964)BASIC (1964)• Pascal (1970)• Smalltalk (1972)• C (1972)

Page 7: Programming Paradigm & Languages

Programming Languages

• Ada(1983) • C++ (1983-85)• QBasic (1986)• Perl (1987)• VisualBasic (1991)• PowerBuilderJava (1995)• JavaScriptC# (2001)

Page 8: Programming Paradigm & Languages

Programming Language

A language used to write instructions for the computer. That is the way of representation any program in to that form which is understandable by CPU.

Page 9: Programming Paradigm & Languages

Programming Language

Programs are written by using any language and these languages set the procedures & rules to write computer programs. Programmers have to follow that rules which is set by programming languages. Types of Languages1)Low Level Language2)High Level Language

Page 10: Programming Paradigm & Languages

LOW LEVEL LANGUAGE

Low level language is also called machine language. That types of languages are close to machine and easily understand by machine as, it is majorly in binary form (0 & 1). low level language types are Machine language Assembly language

Page 11: Programming Paradigm & Languages

HIGH LEVEL LANGUAGE

High level programming languages is languages program than use languages or syntax which closes to human languages so; it is easy to understanding the languages. This type of language is machine-independent, and uses similar language as English, which is easily understandable by human.

Page 12: Programming Paradigm & Languages

TYPES OF HIGH LEVEL LANGUGES

Types of high level languages are:1) Procedural Languages2) Functional & Non procedural Languages3) Object Oriented Languages

Page 13: Programming Paradigm & Languages

Procedural programming languages

FORTRAN (FORmula TRANslation)BASIC (Beginners All Purpose Symbolic

Instruction Code)COBOL (Common Business Oriented Language)

These types of languages are “Third-Generation Language”.

Page 14: Programming Paradigm & Languages

NON PROCEDURAL LANGUGES

In non-procedural languages the computer is not limited to a set of precise instructions. Instead, the programmer defines only the problem—not the instructions--to solve the problem. Non Procedural Programming Languages areSQL (Structured Query Language)LISP (List Processing)PROLOG (PROgramming with LOGic)

Page 15: Programming Paradigm & Languages

Object-Oriented Languages

Programming languages specifically designed to make it easy to implement object-oriented designs

In object-oriented languages, the code used to write the program and the data processed by the program are grouped together into units called objects. Objects are further grouped into classes, which define the attributes objects must have.

Examples: Smalltalk, C++, Java

Page 16: Programming Paradigm & Languages

Language Translator

A translator is a computer program that translates a program written in a given programming language into a functionally equivalent program in a different computer language, without losing the functional or logical structure of the original code

Page 17: Programming Paradigm & Languages

Types of Language Translator

• Compiler• Interpreter• Assembler

Page 18: Programming Paradigm & Languages

COMPILER

A compiler is a computer program that transforms human readable complete code of another computer program into the machine readable code that a CPU can execute.

Page 19: Programming Paradigm & Languages

INTERPRETER

An interpreter is a computer program that reads the source code of another computer program and executes that program. Because it is interpreted line by line, it is a much slower way of running a program than one that has been compiled but is easier for learners because the program can be stopped, modified and rerun without time-consuming compiles.

Page 20: Programming Paradigm & Languages

ASSEMBLER

Assembler converts code written in assembly language into machine language. It works same like interpreter and compiler. The assembler program takes each program statement in the code and generates a corresponding bit stream or pattern (a series of 0's and 1's of a given length).

Page 21: Programming Paradigm & Languages

• Both interpreters and compilers are available for most high-level languages. However, BASIC and LISP were especially designed to be executed by an interpreter

Page 22: Programming Paradigm & Languages

FORTRANFortran is a particularly good language for processing numerical data, but it does not lend itself very well to large business programs

Pascal Pascal is very good for writing well-structured and readable programs, but it is not as flexible as the C programming language

C++ C++ embodies powerful object-oriented features, but it is complex and difficult to learn

Page 23: Programming Paradigm & Languages

Testing & Debugging

•Testing: The tasks performed to determine the existence of defects

•Debugging: The tasks performed to detect the exact location of

defects

•Defects are also called bugs or errors•Let us now look at one of their classifications

Page 24: Programming Paradigm & Languages

Types of Errors

•Syntax errors•Semantic errors•Run-time errors

Page 25: Programming Paradigm & Languages

Syntax Errors

•They are caused by the code that somehow violates the rules of the language

•Easy to detect and fix errors•The browser stops code interpretation on detecting

one of these•Examples:a = b + * c ;receiver = receiver + 2Syntax error?

Page 26: Programming Paradigm & Languages

Semantic Errors

•Occur when a statement executes and has an effect not intended by the programmer

•Hard to detect during normal testing•Often times occur only in unusual & infrequent

circumstances•The „+‟ operator often results in unintended

consequences. Remedy: Convert, before use

Page 27: Programming Paradigm & Languages

Run-Time Errors

•Occur when the program is running and tries to do something that is against the rules

•Example: Accessing a non-existent variable, property, method, object, etc (e.g. a method name is misspelled)

•Sources of these can be determined by a careful reading of the code, but unfortunately, not always!