LANGUAGE TRANSLATORS: WEEK 9

Download Report

Transcript LANGUAGE TRANSLATORS: WEEK 9

Computing Science: WEEK 17
Announcement: next few weeks…
9nd Feb: Comparative Programming Languages +
Prolog - TLMc
16th Feb: Prolog - TLMc
23rd Feb: Prolog - TLMc
School of Computing and Mathematics, University of Huddersfield
Computing Science: WEEK 17
LECTURE:
Comparative Programming Languages + Prolog
PRACTICALS:
Follow notes on Blackboard OR on web –
http://scom.hud.ac.uk/scomtlm/prolog/
- Use a web browser and follow instructions!
School of Computing and Mathematics, University of Huddersfield
Languages for Computers



A great percentage of people in the world use
computers nowadays – they run application tools
and packages such as games, photo
manipulation, email, spreadsheets, information
retrieval, word processing, web browsers …..
The language of interface has to be simple and
specific to the application – usually clicking a
mouse on a menu.
These tools and packages are specific and
confined – its not possible to create OTHER tools
and packages from them ..
School of Computing and Mathematics, University of Huddersfield
Languages for Computers


Computing scientists and engineers need to know
how to design, implement, maintain, test.
evaluate etc these applications
To do so you must to some extent ‘unlearn’ the
pointing, clicking, dragging, dropping of the
masses – you need to learn Programming,
Design, Database, Specification, Web Languages
and expert development environments and open
operating systems such as Unix.
School of Computing and Mathematics, University of Huddersfield
Algorithms
Fundamental to being a computer expert is the
knowledge of ‘Algorithms’. An Algorithm is a step
by step (or systematic) method of solving a
problem written in enough detail so that a
computer can carry it out.
You encode Algorithms using Programming
Languages.
School of Computing and Mathematics, University of Huddersfield
Programming Languages – Procedural
There are literally thousands of Programming Languages.
Most are PROCEDURAL (or STATE based) because they
rely on storing data values (or objects) in VARIABLES.
Steps in an algorithm update the values in the variables until a
desired result. Example:
Static int factorial(int n)
{ m = 1;
while (n > 0) {m=n*m; n=n-1;}
return m;
}
If n >= 0 this returns the factorial of n.
School of Computing and Mathematics, University of Huddersfield
Programming Languages – Functional


Algorithms can be represented functionally. Functional
languages use no assignment or loops.
Algorithm execution is carried out by function evaluation.
Example:
factorial(n) = if (n = 0) then 1 else n*factorial(n-1)
If n >= 0 this returns the factorial of n.
School of Computing and Mathematics, University of Huddersfield
Programming Languages – Logical


Algorithms can be represented as logic rules and facts.
Logic languages use recursive rules to encode ‘loops’.
Algorithm execution is carried out by matching and logical
inference.
Example:
factorial(0,1).
factorial(1,1).
factiorial(N,M) :- P is N-1, factorial(P,Q), M is N*Q.
If N >= 0 this returns the factorial of N.
School of Computing and Mathematics, University of Huddersfield
Programming Languages – PROLOG




Prolog is a logic language
It is used in research and development
applications, in prototyping, and in areas such as
language processing and artificial intelligence
It is an INTERPRETED language –you do not
need to COMPILE code. You run the Prolog
interpreter, load in your Prolog program, and run
it.
Prolog programs are lists of facts and rules.
School of Computing and Mathematics, University of Huddersfield
Summary
-
-
-
-
-
Algorithms are detailed, step by step methods
for solving problems
We encode algorithms using programming
languages
There are thousands of programming
languages – most are PROCEDURAL (they
include sequences of commands)
There are two other important ways to encode
algorithms – functional and logical
Prolog is an important logical language which
we will look at for the next few weeks
School of Computing and Mathematics, University of Huddersfield