ch1 language design issue

26
Programming Language Paradigms Chapter 1 Language Design Issues

Upload: jigisha-pandya

Post on 07-May-2015

293 views

Category:

Technology


1 download

DESCRIPTION

Programming language paradigm

TRANSCRIPT

Page 1: Ch1 language design issue

Programming Language Paradigms

Chapter 1Language Design Issues

Page 2: Ch1 language design issue

Why Study Programming Language?

1. To improve ability to develop effective algorithms:– Many languages provide features that when used properly are of

benefit to programmer but when use improperly may west large amount of computer time, consuming logical errors.

– Even programmer who has used a language for years may not understand features.

– A typical example is recursion.– New programming methods are constantly being introduced in

the literature.– Use of best concept like object oriented programming, logical

programming or concepts.

Page 3: Ch1 language design issue

Why Study Programming Language?(cont.)

2. To improve your use of your existing programming language:– By understanding how features in your language

are implemented, greatly increase your ability to write efficient program.

– For example understanding how data in array, string or records are created and manipulated, by understanding class, objects or recursion you can build more efficient program.

Page 4: Ch1 language design issue

Why Study Programming Language?(cont.)

3. To allow better choice of programming language: – Knowledge of variety of languages may allow the

choice of just language for particular project, there by reducing required coding efforts.

4. To make it easier to learn a new language:– Varity of programming language constructs and

implementation techniques allows the programmer to learn a new programming language more easily.

Page 5: Ch1 language design issue

Why Study Programming Language?(cont.)

5. To make easier to design a new language:– For programmer who think of themselves as

designers can need to have deep understanding of basic languages.

– For example many new languages are based on c or pascal as implementation models. This aspect of program design is often simplified if the programmer is familiar with a variety of constructs and implementation methods from ordinary programming language.

Page 6: Ch1 language design issue

What is Programming Language?

• A language designed for programming computers.

• A programming language is an artificial language designed to communicate instructions to a machine, particularly a computer. Programming languages can be used to create programs that control the behavior of a machine and/or to express algorithms precisely.

Page 7: Ch1 language design issue

What is Programming Language?

• Programming languages are essentially carefully designed notations.

• Programming language use to specify, organize different aspect of problem solving.

• The designer of programming languages have twin goal:– Making computing convenient for people– Making efficient use of computing machine.

Page 8: Ch1 language design issue

Evolution of software Architecture• Evolution of software is a step by step process

Page 9: Ch1 language design issue

Evolution of software Architecture(cont.)

• The computing industry has now entered in third major era in the development of computer program.

• For certain class of problem certain software or languages are defined which is tested, modified and used with minimum investment.

• Smalltalk and Perl are cost effective in that the overall time and effort expended in solving a problem on computer.

Page 10: Ch1 language design issue

Evolution of software Architecture(cont.)

• Maintenance:– Evolution of software also include maintenance, as

studies have shown that the largest cost involved in any program that is used over a period of year is not the cost of initial design, coding and testing of program but total life cycle costs include development as well as maintenance.

– Maintenance includes repair error, changes in program if required as the underlying hardware or operating system is updated and extension and enhancement of program.

Page 11: Ch1 language design issue

Attributes of language

• Syntax and Semantics:– The Syntax of a programming language is what the

program looks like.– The Semantics of a programming language is the

meaning given to the various syntactic constructs.– For example in C to declare vector V, of integers

• Int v[10]

– In contrast in Pascal specified as• V array[0…9]of integer

– Although they create same object at run time, their syntax is different

Page 12: Ch1 language design issue

Language Paradigms

• There are four basic computational models that describe most programming today– Imperative– Applicative – Rule based– Object Oriented

Page 13: Ch1 language design issue

Language Paradigms

• Imperative languages:– Imperative or procedural languages are command

driven or statement oriented languages.– The basic concept is the machine state the set of

all values for all memory locations in the computer.

– A program consists of a sequence of statements and the execution of each statements cause the computer to change the value of one or more locations in its memory that is enter a new state.

Page 14: Ch1 language design issue

Language Paradigms

• The syntax of such languages generally has the form

• Statment1;• Statmenet2;

• Applicative language:– An alternative view of the computation performed

by a programming language is to look at the function that the program represents rather than just the stat changes as the program executes, statement by statement.

Page 15: Ch1 language design issue

Language Paradigms - Applicative language

• In applicative language rather than looking at sequence of states that the machine must pass through in achieving an answer the question to be asked is what is the function that must be applied to initial machine state by accessing initial data.

• We can view this model as a lens that takes the initial data and by manipulating the view of memory, produce the desired answer.

• Program development proceeds by developing functions from previously developed functions to build more complex function.

Page 16: Ch1 language design issue

Language Paradigms – Rule based language

• Rule based languages execute by checking for the presence of certain enabling condition and when present, executing an appropriate action the most common rule based language is prolog also called a logic programming language.

• Enabling conditions determine the order of execution

• The syntax is – Enabling condition action1– Enabling condition action2

Page 17: Ch1 language design issue

Language Paradigms – Object Oriented Programming

• Object Oriented Programming: In this case complex data object are build , then a limited set of functions are designed to operate on those data.

• Complex object are designed as execution of simple objects, inheriting property of simpler objects.

Page 18: Ch1 language design issue

Language standardization

• The need for standards - to increase portability of programs

• Problem: When to standardize a language?

• If too late - many incompatible versions

• If too early - no experience with language

• Problem: What happens with the software developed before the standardization?

•   Ideally, new standards have to be compatible with older standards.

Page 19: Ch1 language design issue

Internationalization

• How to specify languages useful in a global economy?

• What character codes to use?

• Collating sequences? - How do you alphabetize various languages?

• Dates? - What date is 10/12/01? 10-12-01? 12.10.01 ?

Is it a date in October or December?

Page 20: Ch1 language design issue

Internationalization

• Time? - How do you handle

• time zones,

• summer time in Europe,

• daylight savings time in US,

• Southern hemisphere is 6 months out of phase with northern hemisphere,

• the date to change from summer to standard time is not consistent.

• Currency? - How to handle dollars, pounds, marks, francs, euros, etc.

Page 21: Ch1 language design issue

Timeliness

• One important issue is when to standardize a language. FORTRAN was initially standardized in 1966 after there were many incompatible version.

• This lead a problem because each implementation is different from others.

• At the other extreme Ada was standardized in 1983 before there were any implementations

• When it was not clear weather the language would even work.• The first effective Ada compiler did not appear until 1987• C and Pascal were standardized while growing and before there

were too many incompatible version.

Page 22: Ch1 language design issue

Programming environments

Programming environment is where programs are created, tested.Usually consists of support tools and command language for invoking themTypical tools include:• editors• debuggers• verifiers• pretty printers• test data generators

Page 23: Ch1 language design issue

Effects on language design

Programming environments have had two large effects on language design:• Features aiding separate

compilation/assembly from components• Features aiding program testing and

debuggin

Page 24: Ch1 language design issue

Effects on Language Design

Separate compilation:•For large programs, different programmers will be working on separate parts.•This requires a language that can compile the parts and merge together later•Separate compilation can be difficult because subprograms might need each other•There are ways to provide information to subprograms during separate compilation:• Information may need to be redeclared (FORTRAN)• An order of compilation may be required (Ada)• A library containing relevant specifications may be required

(Java/C++)

Page 25: Ch1 language design issue

Effects on Language Design•Option 1 above uses independent compilation. The subprogram is entirely self contained. •The disadvantage is inability to check inconsistency of data between external declaration and internal re declaration. You will have assembly errors even though the subprograms may have 0 errors.•Options 2 and 3 require the use of libraries. The body is usually omitted during the compilation of subprograms.•Separate compilation has the side effect of enabling name collisions issues• Several subprograms or portions of programs may have the same name• This may not be determined until attempting to merge all subprograms

•There are three main ways languages avoid these name collisions• Use of naming conventions (obligation is the programmer's)• Use of scoping rules (Used by Pascal, C, Ada)• Add name definitions from external library(inheritance in Object oriented)

Page 26: Ch1 language design issue

Environment Frameworks

•Support environment: Uses infrastructure services called environment frameworkEnvironment framework: supplies data repository, GUI, security, communication• Ex: An environment framework would contain the following

A window manager such as MotifVB and Visual Studio provide for libraries to build windows