You are on page 1of 17

Principles of

Programming Languages

Lecture 1
Overview of Programming Languages
Lecture outline
● Why so many languages?
● Programming language (PL) features
● What makes a good PL?
● Why study PLs?
● PL spectrum

Duc L. M. FIT325 2
1 Why so many languages?
● Evolution
● Special purposes
● Personal perference

Duc L. M. FIT325 3
2 PL features
● Expressive power
● Ease of use
● Ease of implementation
● Standardisation
● Open source
● Excellent compilers
● Economics, Patronage, and Inertia

Duc L. M. FIT325 4
PL features
● Expressive power ● write clear, concise
● Ease of use & maintainable code
● abstraction
● Ease of implementation
● Standardisation
● Open source
● Excellent compilers
● Economics, Patronage, and Inertia

Duc L. M. FIT325 5
PL features
● Expressive power
● Ease of use ● low learning curve
● Ease of implementation for beginning
programmers
● Standardisation
● Open source
● Excellent compilers
● Economics, Patronage, and Inertia

Duc L. M. FIT325 6
PL features
● Expressive power
● Ease of use
● Ease of implementation ● suitable for average
● Standardisation machines
● accessible (e.g. free
● Open source
for educational use)
● Excellent compilers
● Economics, Patronage, and Inertia

Duc L. M. FIT325 7
A good PL is a compromise!
● Between the desires of programmer and PL
implementor
● Programmer:
● language = means of expressing algorithms
● conceptual clarity
● PL implementor:
● language = means of instructing computers
● implementation efficiency

Duc L. M. FIT325 8
Donald E. Knuth (1938-)

programming be regarded as the art of telling


another human being what one wants the
computer to do

Duc L. M. FIT325 9
3 Why study PLs?
● Know obscure features
● Understand different ways of expressing
● Help choose a PL for a given task
● Make it easier to learn new PLs
● Make good use of common development tools:
● debuggers, assemblers, linkers
● Add new useful features to a language
● Make better use of language technology

Duc L. M. FIT325 10
4 PL spectrum

declarative imperative

template- von object-


functional data flow logic scripting
based neumann oriented

Lisp/Scheme Id, XSLT Prolog, C, Perl, Smalltalk,


ML Val spreadsheet Ada, Python, Eiffel,
Haskell Fortran PHP Java

based on model of computation

Duc L. M. FIT325 11
Comparison
● Declarative language:
● focus more on programmer's than implementor's
view
● describe what rather than how
● Imperative language:
● describe how a program is executed
● The distinctions are not absolute:
● e.g. functional language can also have object-
oriented feature

Duc L. M. FIT325 12
Von Neumann language
● Computation:
● modification of variables
● Side effects:
● value of memory is changed in statements

Duc L. M. FIT325 13
Example: Gcd

int gcd(int a, int b) { // C


while (a != b) {
if (a > b) a = a - b;
else b = b - a;
}
return a;
}

Duc L. M. FIT325 14
Example: Gcd

static int gcd(int a, int b) { // Java


while (a != b) {
if (a > b) a = a - b;
else b = b - a;
}
return a;
}

Duc L. M. FIT325 15
Object oriented language
● Computation:
● interactions among semi-independent objects
● Object has internal state and procedures

Duc L. M. FIT325 16
Summary
● Many PLs exist because of evolution, purpose,
preference
● A good PL strikes a balance between
conceptual clarity and implementation
efficiency
● PL spectrum includes a categorisation of PLs
into declarative and imperative forms
● Study PLs help raise the awareness of and
choose suitable PL(s) for a given task

Duc L. M. FIT325 17

You might also like