Why study programming languages?
Six primary reasons:
o To improve your ability to develop effective algorithms o To improve your use of your existing programming language o To increase your vocabulary of useful programming constructs o To allow a better choice of programming language
o To make it easier to learn a new language o To make it easier to design a new language
Attributes of a good language:
o Clarity, simplicity, and unity
provides both a framework for thinking about algorithms and a means of expressing those algorithms
Have a minimum number of different concepts, with the rules for their combination, simple and regular (conceptual integrity).
readability
o Orthogonality
Being able to combine various features of a language in all possible combinations. every combination of features is meaningful
o Naturalness for the application
program structure reflects the logical structure of algorithm o Support for abstraction
program data reflects problem being solved Attributes of a good language (continued) o Ease of program verification
verifying that program correctly performs its required function o Programming environment
external support for the language o Portability of programs
transportability of the resulting programs from the computer on which they are developed to other computer systems
o Cost of use
Cost of program execution Cost of program translation Cost of program creation Cost of program maintenance
Influences on Programming languages:
o Computer capabilitiesHardware and OS o Applications
Wide area of applications o Programming methods
Multiprogramming, interactive systems, data abstraction, formal semantics, OO programming,…
o Implementation methods
The development of better implementation methods has affected the choice of feature to include in new language designs.
o Theoretical studies
Deep research using formal mathematical methods for understanding of the strengths and weaknesses of language features which has influence the inclusion of these features in new language designs
o Standardization
Need for standard languages that can be implemented easily on a variety of computer systems
Choosing language for application
o Pascal, C – procedural, statement oriented o C++, Java, Smalltalk – Object oriented o ML, Lisp – Functionalo Prolog – Rule-based
Language paradigms
(also refer complete theory from Page No. 4)o Imperative languages
Goal is to understand a machine state (set of memory locations, each containing a value)
Statement oriented languages that change machine state (C, Pascal, FORTRAN, COBOL)
Syntax: Statement1; Statement2; ….
o Applicative (functional) languages
Goal is to understand the function that produces the answer Function composition is major operation (ML, LISP)
Syntax: functionN(…function2(function1 (data))…)
Programming consists of building the function that computes the answer o Rule-based languages
Rule-based or logical languages execute by checking for the presence of a certain condition and when it is satisfied, they execute an appropriate action.
Specify rule that specifies problem solution (Prolog, BNF Parsing) Other examples: Decision procedures, Grammar rules (BNF) Programming consists of specifying the attributes of the answer The syntax has the form like:
enabling condition1 action1 enabling condition2 action2 …
enabling conditionN actionN o Object-oriented languages
Object-oriented languages can be viewed as combining imperative and functional paradigms. • Abstract data types
• inheritance
efficiency of imperative languages
Flexibility and reliability of functional languages.
Syntax: Set of objects (classes) containing data (imperative concepts) and methods (applicative concepts)
e.g. Java, C++, Smalltalk
Creation of standards
o Language standards defined by national standards bodies: ISO – International Standards organization
IEEE – Institute of Electrical and Electronics Engineers ANSI – American National Standards Institute
o All work in a similar way:
Working group of volunteers set up to define standard Agree on features for new standard
Vote on standard
If approved by working group, submitted to parent organization for approval. Standards in the US are voluntary:
There is no federal standards-making organization.
that are only required on federal agencies, not for commercial organizations. But: Consensus is the key to standards making:
Contentious features often omitted to gain consensus Only vendors have a vested interest in the results
Users don’t care until standard approved, and then it is too late!
Classes of Binding Times
(also refer complete theory from Page No. 8)1. Execution time (run time) (dynamic binding) On entry to subprogram or block.
o Binding of formal to actual parameters in C. At arbitrary points during execution
o Binding of variables to values by assignments. (can be modified repeatedly during execution)
2. Translation time (compile time)
Bindings chosen by the programmer o Variable names and types Bindings chosen by the translator
o Relative locations of a data object in the storage allocated for a procedure Bindings chosen by the loader
o Actual addresses 3. Language implementation time
The details associated with the representation of numbers and of arithmetic operations. (integer type memory representation)
4. Language definition time
Possible statement forms, data structure types, program structures. (integer type definition)
Storage-Management Phases
1. Initial allocationAt start of execution, each piece of storage may either be allocated for some use or free. If free initially, it is available for allocation dynamically as execution proceeds. Any storage management system requires some technique for keeping track of free storage as well as mechanisms for allocation of free storage as the need arises during execution.
2. Recovery
Storage that has been allocated and used, and that subsequently becomes available, must be recovered by the storage manager for reuse.
Recovery may be very simple, as in the repositioning of a stack pointer, or very complex, as in garbage collection.
3. Compaction and reuse
Storage recovered may be immediately ready for reuse or compaction may be necessary to construct large block of free storage from small pieces. Reuse of storage ordinarily involves tha same mechanisms as initial allocation.