Date post: | 07-Dec-2014 |
Category: |
Technology |
Upload: | palak-sanghani |
View: | 290 times |
Download: | 3 times |
Programming Languages
Lecture 1
Naveen Kumar
The Study of Programming Languages
The purpose of language is simply that it must convey meaning (Confucius)
Whatever can be said, can be said clearly (Wittgenstein,1963)
A programming language is a notation for writing programs (Sethi,89)– program is a specification of a computation.2
What is a programming language?
A language that is intended for the expression of computer programs and
that is capable of expressing any computer program
3Computer program is a specification of a computation.
What is Programming Language
4
ComputerProgram
Programming Language
Output
use
giveswriteUser
executes
Problem
takes
A short history of programming Languages
Early languages:– Numerically based languages. (FORTRAN:55,ALGOL:58)– Business languages. (COBOL:60)– Artificial intelligence languages. (LISP,Prolog)– Systems languages. (C:70)
1950 : LISP, FORTRAN, COBOL, ALGOL60, BASIC 1970 : Ada, C, Pascal, Prolog 1980 : C++ 1990 : Delphi, Perl 1996 : Java by James Gosling (at SUN Micro Systems)5
Attributes of a good language
Clarity and simplicity– Readability
Naturalness for the application Ease of program verification
– Proof of correctness, test– Simplicity of semantic and syntax
Portability of programs Cost of use
– Program execution– Program translation– Program creation, testing, and use– Program maintenance6
Programming Methodology
Kind of approach to solve different problems
How should programs be designed?
How should programs be structured?
Programming Methodologies Influences
1950s and early 1960s: Simple applications; worry about machine efficiency
Late 1960s: People efficiency became important; readability, better control structures
– structured programming– top-down design
Late 1970s: Process-oriented (Goal or.) to data-oriented (DB or.)
– data abstraction
Middle 1980s: Object-oriented programming– Data abstraction + inheritance + polymorphism
Kinds of Programming Methodology
Unstructured programming Procedural/Process oriented programming
– Modular programming Object-oriented programming
Unstructured Programming
Direct code (step)
Ex: Assembly LanguageAdv. speed (written in assembly)Disadv. No re-usability Statements written many times As code increases, complexity increases
– Hard to manage large programs – Hard to debug
Procedural oriented Programming
Top-down approach Procedure (Function) are building block De-allocation problem (memory leak: memory allocated
but not used) Un- initialized Variables (rand value assigned)Ex: Calculator → scientific
→ non-scientific → float→ int → add.
→ subs.→ mult.→ div.
Ex: C - language
Smallfunctions
Procedural oriented Programming
Adv:– Re-usability– Easy to debug
Disadv:– Concentrate on what we want to do, not on who will use it– Data does not have a owner (sharing) – All functions are global– No data security
Ex: let there are three functions a(),b() and c(). Data d is used by a() and b() but how to restrict from c() [data will be either global or local]
– No data integrity [Stack:{push,pop},Queue:{enque, deque}] How to distinguish which fun associated with which data
structure
Object-Oriented Programming
Keep large software projects manageable by human programmers
Bottom-up approach (user oriented) Objects are building block
An Example
Everything in OOP is grouped as self sustainable "objects".
let’s take your “hand” as an example. – Your body has two objects of type hand, named left hand and
right hand. Their main functions are controlled/ managed by a set of electrical signals sent through your shoulders
– So the shoulder is an interface which your body uses to interact with your hands.
– The hand is being re-used to create the left hand and the right hand by slightly changing the properties of it.
14
Another Example
Ex: college (Student, Faculty, Admin)
Student (take course, write exam, view indv. result)Faculty (set paper, prepare result, view results)Admin (student admission, staff/faculty selection)
15
Why OOP?
Modularization Decompose problem into smaller
subproblems that can be solved separately.
16
Why OOP?
Abstraction -- Understandability
Individual modules are understandable by human readers.
17
Why OOP?
Encapsulation -- Information Hiding
Hide complexity from the user of a software. Protect low-level functionality.
18
Why OOP?
Composability -- Structured Design
Interfaces allow to freely combine modules to produce new systems.
19
Why OOP?
Hierarchy
Incremental development from small and simple to more complex modules.
20
Complexityincreases
Why OOP?
Continuity
Changes and maintenance in only a few modules does not affect the architecture.
21
Main OOP Language Features
Classes: Modularization, structure. Inheritance / extends: Hierarchy of modules,
incremental development. Public / Protected / Private: Encapsulation. Interfaces / Abstract Classes: Composability. Polymorphism / virtual: Hierarchy of modules,
incremental development. Templates: Type independent abstract data
types. 22