2. What is a Programming Language ?
A programming language is a set of rules that provides a way of
telling a computer what operations to perform.
A Programming language is a tool for developing executable
models for a class of problem domains.
3. Syntax, Semantics and Pragmatics
Syntax:
Structure of Programs (tokens, keywords, statements)
Semantics:
What are meant by programs.
Pragmatics:
4. Language Paradigms
Imperative/ Procedural Languages
Applicative/ Functional Languages
Rule-based / Declarative Languages
Object-Oriented Languages
5. Imperative/ Procedural Languages
Statement Oriented languages that change machine state
EX: (C, Pascal, FORTRAN, COBOL)
Computation: a sequence of machine states(contents of memory)
Syntax: S1, S2, S3,… where S1, S2,… are statements
6. Imperative/ Procedural Languages
Imperative programs emphasize “tell what to do”
They focus on evaluating expressions and storing results in a variable.
The most common imperative language consists of statements such as :
a=10;
b= 5;
c=a + b;
7. Applicative/ Functional Languages
Programming consists of building the function that computes the answer
EX: (ML, LISP)
Computation: Function Composition is major operation
Syntax: F1(F2(F3(X))) where F1, F2,F3 are functions and X is data.
8. Rule-Based / Declarative Languages
Computation: Actions are specified by rules that check for the presence of
certain enabling conditions. EX (Prolog)
The order of execution is determined by the enabling conditions, not by
the order of the statements.
Syntax: Condition Action
9. Object-Oriented Languages
Imperative languages that merge applicative design with imperative
statements.
Ex: (java, C++, Smalltalk)
Syntax: set of objects (classes) containing data (imperative concepts) and
methods (applicative concepts)
10. Different Types of Programming Domains
Scientific applications
Business applications
Artificial intelligence
Scripting languages
Systems Programming
11. Programming Domains (Cont.’…)
Scientific applications
-Large number of floating point computations
-Ex: Fortran
Business applications
-Produce reports, use decimal numbers and characters
- Ex: COBOL
12. Programming Domains (Cont.’…)
Artificial intelligence
-Symbols rather than number manipulated
-Ex: LISP
Systems Programming
-Need efficiency because of continuous use
- Ex: C
13. Programming Domains (Cont.’…)
Scripting Languages
-Eclectic collection of languages : markup (e.g., XHTML), scripting
(e.g., PHP), general-purpose (e.g., Java)
14. Criteria for Language Evaluation
Readability :the ease with which programs can be read and
understood
Writeability :the ease with which a language can be used to create
programs.
Reliability :conformance to specifications (i.e., performs to its
specifications)
Cost : the ultimate total cost
15. Criteria for Language Evaluation (Cont..)
Readability
o Overall simplicity “Strongly affects readability”
-Too many features make the language difficult to learn.
Programmers tend to learn a subsets of the language and ignore its other
features. Ex. ALGOL 60
- Multiplicity of features is also a complicating characteristics
“having more than one way to accomplish a particular operation. Ex. Java
16. Criteria for Language Evaluation (Cont..)
Readability
o Orthogonality
-Makes the language easy to learn and read.
- Meaning is context independent. Pointers should be able to point to
any type of variable or data structure.
17. Criteria for Language Evaluation (Cont..)
Readability
o Control Statements
-It became widely recognized that indiscriminate use of goto statements
severely reduced program readability.
- Basic and Fortran in the early 70s lacked the control statements that
allow strong restrictions on the use of gotos, so writing highly readable
programs in those languages was difficult.
18. Criteria for Language Evaluation (Cont..)
Readability
o Control Statements
-Since then, languages have included sufficient control structures.
- The control statement design of a language is now a less important
factor in readability that it was in the past.
19. Criteria for Language Evaluation (Cont..)
Readability
o Data Types and structures
-The presence of adequate facilities for defining data types and
structures in a language is another significant aid to reliability.
- Ex: Boolean type.
• timeout =1 or
• timeout=true
20. Criteria for Language Evaluation (Cont..)
Readability
o Syntax Considerations
-The syntax of the elements of a language has a significant effect on
readability.
-Identifier forms: Restricting identifiers to very short length detracts from
readability. ANSI BASIC(1978) an identifier could consist only of a single
letter followed by a single digit.
21. Criteria for Language Evaluation (Cont..)
Writability
-It is a measure of how easily a language can be used to create programs
for a chosen problem domain
- Most of the language characteristics that affect readability also affect
writability.
22. Criteria for Language Evaluation (Cont..)
Writability
o Support for abstraction
-The ability to define and use complex structures or operations in ways
that allow details to be ignored.
-
23. Criteria for Language Evaluation (Cont..)
Writability
o Simplicity and Orthogonality
-A smaller number of primitive constructs and a consistent set of rules
for combining them is much better than simply having a large number of
primitives.
24. Criteria for Language Evaluation (Cont..)
Reliability
o Type checking
-is simply testing for type errors in a given program, either by the
compiler or during program execution.
o Exception handling
-the ability to intercepts run-time errors, take corrective measures, and
then continue is a great aid to reliability.
25. Criteria for Language Evaluation (Cont..)
Cost
o Training programmers to use language.
o Compiling Programs
o Maintaining Programs
o Language implementation system: availability of free compilers
o Reliability: poor reliability leads to high costs.