Programming Languages: An Introduction
Application domains
• Scientific applications
– typically require simple data structures but a large number of
flating-point operations
– typical data structures: arrays and matrices;
typical control constructs: selection and loop
– earliest high-level language: FORTRAN
other language: ALGOL 60
• Business applications
– requires preparation of detailed, complex reports and precise
ways of handling decimal numbers and character data
– most popular language: COBOL
• Systems programming applications
– systems software is used almost continuously and so a lan-
guage for systems programming must have fast execution.
– a language used for systems programming must have low-level
featurs to access external devices.
– popular language: C (almost the whole of UNIX is written in
C)
• Artificial intelligence applications
– requires symbolic rather than numeric processing
– typical data structure: linked list
– popular languages: LISP, PROLOG
1
• Scripting languages
– these languages put a list of commands, called a script, in a
file to be executed
– initially scripts performed simple utilities, e.g, file filtering;
example sh
– variables, control structures, functions added, creating a com-
plete programming language; example: ksh
• Special-purpose languages
– a variety of application-specific languages (or software tools);
example: RPG (business report generator), GPSS (systems
simulation)
– many computer scientists do not consider these to be program-
ming languages
Names of some languages
FORTRAN: FORmula TRANslation
ALGOL: ALGOrithmic Language
BASIC: Beginner’s All-purpose Symbolic Instruction Code
COBOL: COmmon Business Oriented Language
LISP: LISt Processing
PROLOG: PROgramming in LOGic
Language evaluation criteria
• Readability (maintenance vs. coding in software life cycle)
• Writability
• Reliability
Readability
• Simplicity
2
– Too many constructs may cause problems
– Mulitiplicity of features does not help
Example: i = i + 1;
i+ = 1;
i + +;
+ + i; (l-value and r-value problems)
– Inefficient use of operator overloading
– Too much simplicity is bad (ex: assembly language)
• Orthogonality
– Orthogonality requires every possible combination of primi-
tives to be legal
– Example: VAX assembly language addition: ADDL op-1, op-
2
IBM assembly language addition:
A register-1, memory-cell-1
AR register-1, register-2
– Too much orthogonality is bad;
Example: a conditional appearing on the left side of an as-
signment
– Functional languages provide a good mix of simplicity and
orthogonality
• Control constructs
– the 3 basic constructs
– controlled branching: break, continue
– uncontrolled jump: go to
– restricted jump:
∗ use forward go to’s only
∗ do not jump very far
∗ use as few go to’s as possible
– structured programming; proper programs; Mills’ theorem
3
• Data types supported
Example: A language with no boolean variable
• Other features supported
Example: SORT, MERGE verbs in COBOL
• Sysntax issues
– identifier length restrictions: FORTRAN, COBOL
– reserved words
Writability
• Simplicity
• Orthogonality
• Abstraction support
• Expressivity (being cryptic is not necessarily a virtue)
Reliability
• Type checking
• Aliasing
• Exception handling
Cost
• Cost of training programmers
• Cost of writing programs
• Cost of compilation
• Cost of execution vs. cost of compilation: student environment and
production environment
• Costs arising out of unreliable performance
• Costs of program maintenence
4
Main factors affecting language design
• The von Neumann architecture: imperative programming
• Methodologies:
– 1950s and 60s: focus on machine efficiency; simple applica-
tions
– Late 60s: focus on programmer productivity; better control
structures
– Late 70s: data abstraction
– mid-80s: object-oriented programming
Language categories
• Imperative
• Functional
• Logic
• Object-oriented
Language implementation strategies
• Compilation
– slow translation
– fast execution
• Interpretation
– no translation
– slow execution
• Hybrid methods
– moderate translation cost
– medium execution speed