unit i - kainjan1.files.wordpress.com€¦ · input-output control unit alu store data and program...
TRANSCRIPT
Programming Language Syntax and semantics
UNIT I
BB yy
Kainjan Sanghavi
Contents
• Language and Computer Architecture • Programming Language Qualities : • Language and Reliability • Language and Maintainability • Language and Efficiency • Brief Historical Perspective • Early High Level languages
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.
(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
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)
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
Maintainability is achieved
by….
Factoring
Locality
Maintainability
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
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.
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
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
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...
What Are the Types
of Programming
Languages First Generation Languages Second Generation Languages Third Generation Languages Fourth Generation Languages Fifth Generation Languages
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.
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.
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
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.)
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
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
EARLY HIGH LEVEL
LANGUAGES
FORTRAN LISP ALGOL
COBOL BASIC
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.
Early High-level Languages
LISP
•LISt Processing
•Developed by John McHarthy in 1958.
•Designed for symbolic computations
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
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
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
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
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.
Thank You!
Angelin