unit i - kainjan1.files.wordpress.com€¦ · input-output control unit alu store data and program...

28
Programming Language Syntax and semantics UNIT I BByy Kainjan Sanghavi

Upload: others

Post on 18-Oct-2020

5 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: UNIT I - kainjan1.files.wordpress.com€¦ · Input-Output Control Unit ALU Store data and program Execute program Do arithmetic/logic operations requested by program Communicate

Programming Language Syntax and semantics

UNIT I

BB yy

Kainjan Sanghavi

Page 2: UNIT I - kainjan1.files.wordpress.com€¦ · Input-Output Control Unit ALU Store data and program Execute program Do arithmetic/logic operations requested by program Communicate

Contents

• Language and Computer Architecture • Programming Language Qualities : • Language and Reliability • Language and Maintainability • Language and Efficiency • Brief Historical Perspective • Early High Level languages

Page 3: UNIT I - kainjan1.files.wordpress.com€¦ · Input-Output Control Unit ALU Store data and program Execute program Do arithmetic/logic operations requested by program Communicate

Language and Computer

Architecture

Computer architecture restricts Programming language

Most of the languages follow Von Neumann Architecture

Functional and logical languages discarded Von Neumann and follow mathematical foundations instead of hardware.

Page 4: UNIT I - kainjan1.files.wordpress.com€¦ · Input-Output Control Unit ALU Store data and program Execute program Do arithmetic/logic operations requested by program Communicate

(c) Yngvi Bjornsson 4

The Von Neumann Architecture

Memory

Processor (CPU)

Input-Output Control Unit

ALU

Store data and program

Execute program

Do arithmetic/logic operations

requested by program

Communicate with

"outside world", e.g.

• Screen

• Keyboard

• Storage devices

• ...

Bus

Page 5: UNIT I - kainjan1.files.wordpress.com€¦ · Input-Output Control Unit ALU Store data and program Execute program Do arithmetic/logic operations requested by program Communicate

Programming language qualities

Software must be reliable ( no failure)

Software must be maintainable(new requirements be easily added ..or modified)

Software must be efficient( speedy and less space)

Page 6: UNIT I - kainjan1.files.wordpress.com€¦ · Input-Output Control Unit ALU Store data and program Execute program Do arithmetic/logic operations requested by program Communicate

Reliability is achieved by….

• Higher-level languages are more writable than low-level Writability

• Provision of adding new operations and data types easily enhances readability Readabililty

• Allow algorithms to be expressed easily, Eg. Pascal is simpler than C++ but less powerful Simplicity

• If language provides no features that make it possible to write harmful programs..like goto then its safe Safety

• Ability to deal with undesired events like arithmetic overflow. Robustness

Page 7: UNIT I - kainjan1.files.wordpress.com€¦ · Input-Output Control Unit ALU Store data and program Execute program Do arithmetic/logic operations requested by program Communicate

Maintainability is achieved

by….

Factoring

Locality

Maintainability

Page 8: UNIT I - kainjan1.files.wordpress.com€¦ · Input-Output Control Unit ALU Store data and program Execute program Do arithmetic/logic operations requested by program Communicate

Maintainability is achieved

by…. Fa

cto

rin

g 1. The language should allow programming to factor related features into one single unit.

2. Example If an operation is repeated in several point of the program it should be possible to factor it in a routine and replace its use by a routine call. In doing so the program become more readable especially if we given meaningful names to routines and is more easily modifiable like a change to the fragment is localized to the routine body.

3. Several programming language allow constants to be given symbolic names. Choosing an appropriate name for a constant promotes readability of the program

Page 9: UNIT I - kainjan1.files.wordpress.com€¦ · Input-Output Control Unit ALU Store data and program Execute program Do arithmetic/logic operations requested by program Communicate

Maintainability is achieved

by…. Lo

calit

y 1. The effect of language feature is restricted to small local portion of the entire program otherwise if it extends to most of the program the task of making the changes can be exceedingly complex.

2. Example In abstract data type programming the change to a data structure, defined inside a class is guaranteed not to affect the rest of the program as long as the operations that manipulate the data structure and invoked in the same way.

Page 10: UNIT I - kainjan1.files.wordpress.com€¦ · Input-Output Control Unit ALU Store data and program Execute program Do arithmetic/logic operations requested by program Communicate

Language and Efficiency..

Efficiency earlier was measured by execution speed and space

Now-a-days we can measure it by combined quality of language and its implementation

If a language does not allow optimization it may adversely affect efficiency

Page 11: UNIT I - kainjan1.files.wordpress.com€¦ · Input-Output Control Unit ALU Store data and program Execute program Do arithmetic/logic operations requested by program Communicate

Brief historical perspective…Different

category of programming languages

In early days computer was used mainly in

scientific applications.

Application was programmed by one person

SDLC consisted of only implementation phase

Page 12: UNIT I - kainjan1.files.wordpress.com€¦ · Input-Output Control Unit ALU Store data and program Execute program Do arithmetic/logic operations requested by program Communicate

Levels of Programming

Languages High-level program

class Triangle {

...

float surface()

return b*h/2;

}

Low-level program

LOAD r1,b

LOAD r2,h

MUL r1,r2

DIV r1,#2

RET

Executable Machine code

0001001001000101

0010010011101100

10101101001...

Page 13: UNIT I - kainjan1.files.wordpress.com€¦ · Input-Output Control Unit ALU Store data and program Execute program Do arithmetic/logic operations requested by program Communicate

What Are the Types

of Programming

Languages First Generation Languages Second Generation Languages Third Generation Languages Fourth Generation Languages Fifth Generation Languages

Page 14: UNIT I - kainjan1.files.wordpress.com€¦ · Input-Output Control Unit ALU Store data and program Execute program Do arithmetic/logic operations requested by program Communicate

First Generation

Languages Machine language

• Operation code – such as addition or subtraction.

• Operands – that identify the data to be processed.

• Machine language is machine dependent as it is the only language the computer can understand.

• Very efficient code but very difficult to write.

Page 15: UNIT I - kainjan1.files.wordpress.com€¦ · Input-Output Control Unit ALU Store data and program Execute program Do arithmetic/logic operations requested by program Communicate

Second

Generation

Languages • Assembly languages • Symbolic operation codes replaced binary

operation codes. • Assembly language programs needed to be

“assembled” for execution by the computer. Each assembly language instruction is translated into one machine language instruction.

• Very efficient code and easier to write.

Page 16: UNIT I - kainjan1.files.wordpress.com€¦ · Input-Output Control Unit ALU Store data and program Execute program Do arithmetic/logic operations requested by program Communicate

Closer to English but included simple mathematical notation.

• Programs written in source code which must be translated into machine language programs called object code.

• The translation of source code to object code is accomplished by a machine language system program called a compiler.

Third Generation

Languages

Page 17: UNIT I - kainjan1.files.wordpress.com€¦ · Input-Output Control Unit ALU Store data and program Execute program Do arithmetic/logic operations requested by program Communicate

Alternative to compilation is interpretation which is accomplished by a system program called an interpreter. Common third generation languages

• FORTRAN • COBOL • C and C++ • Visual Basic

Third Generation

Languages (cont’d.)

Page 18: UNIT I - kainjan1.files.wordpress.com€¦ · Input-Output Control Unit ALU Store data and program Execute program Do arithmetic/logic operations requested by program Communicate

A high level language (4GL) that requires fewer instructions to accomplish a task than a third generation language. Used with databases

• Query languages • Report generators • Forms designers • Application generators

Fourth Generation

Languages

Page 19: UNIT I - kainjan1.files.wordpress.com€¦ · Input-Output Control Unit ALU Store data and program Execute program Do arithmetic/logic operations requested by program Communicate

Declarative languages Functional(?): Lisp, Scheme, SML

• Also called applicative • Everything is a function

Logic: Prolog • Based on mathematical logic • Rule- or Constraint-based

Fifth Generation

Languages

Page 20: UNIT I - kainjan1.files.wordpress.com€¦ · Input-Output Control Unit ALU Store data and program Execute program Do arithmetic/logic operations requested by program Communicate

EARLY HIGH LEVEL

LANGUAGES

FORTRAN LISP ALGOL

COBOL BASIC

Page 21: UNIT I - kainjan1.files.wordpress.com€¦ · Input-Output Control Unit ALU Store data and program Execute program Do arithmetic/logic operations requested by program Communicate

Early High-level Languages

FORTRAN

•FORmula TRANslation.

•Developed at IBM in the mid-1950s (1954) .

•Designed for scientific and mathematical applications by scientists and engineers.

Page 22: UNIT I - kainjan1.files.wordpress.com€¦ · Input-Output Control Unit ALU Store data and program Execute program Do arithmetic/logic operations requested by program Communicate

Early High-level Languages

LISP

•LISt Processing

•Developed by John McHarthy in 1958.

•Designed for symbolic computations

Page 23: UNIT I - kainjan1.files.wordpress.com€¦ · Input-Output Control Unit ALU Store data and program Execute program Do arithmetic/logic operations requested by program Communicate

ALGOL

• ALGOrithmic Language.

• Developed in Europe in late 1950s.

• Designed for programming numerical computations

• Used Backus Normal Form (BNF) for programming

Early High-level Languages

Page 24: UNIT I - kainjan1.files.wordpress.com€¦ · Input-Output Control Unit ALU Store data and program Execute program Do arithmetic/logic operations requested by program Communicate

COBOL

• COmmon Business Oriented Language.

• Developed in 1959.

• Designed to be common to many different computers.

• Typically used for business applications.

Early High-level Languages

Page 25: UNIT I - kainjan1.files.wordpress.com€¦ · Input-Output Control Unit ALU Store data and program Execute program Do arithmetic/logic operations requested by program Communicate

BASIC

• Beginner’s All-purpose Symbolic Instruction Code.

• Developed at Dartmouth College in mid 1960s.

• Developed as a simple language for students to write programs with which they could interact through terminals.

Early High-level Languages

Page 26: UNIT I - kainjan1.files.wordpress.com€¦ · Input-Output Control Unit ALU Store data and program Execute program Do arithmetic/logic operations requested by program Communicate

C

• Developed by Bell Laboratories in the early 1970s.

• Provides control and efficiency of assembly language while having third generation language features.

• Often used for system programs.

• UNIX is written in C.

Early High-level Languages

Page 27: UNIT I - kainjan1.files.wordpress.com€¦ · Input-Output Control Unit ALU Store data and program Execute program Do arithmetic/logic operations requested by program Communicate

Questionairres

1. What are the different programming language qualities?

2. What is importance of reliability and maintainability to programming languages. List the factors to ensure them.

3. Explain Von Neumann Architecture 4. Explain the different generation languages

and Give examples of each.

Page 28: UNIT I - kainjan1.files.wordpress.com€¦ · Input-Output Control Unit ALU Store data and program Execute program Do arithmetic/logic operations requested by program Communicate

Thank You!

Angelin