close

Вход

Забыли?

вход по аккаунту

?

The Evolution of Programming Languages

код для вставкиСкачать
The Evolution of
Programming Languages
CS 351
Mark Hennessy Dept. Computer
Science NUIM CS351
1. Customized Digital Computer
Task j
Ij
Oj
Task k
Ik
Ok
Rig different circuit for each task
Mark Hennessy Dept. Computer
Science NUIM CS351
2. Stored Program Computing
пЃ¬
von Neumann showed the existence of a
Universal Machine (hardware) that can be
customized using control inputs to carry out
different tasks.
пЃ¬ Software is the encoding of the task to control
this machine.
encoding(Tj)
Ij
Oj
Mark Hennessy Dept. Computer
Science NUIM CS351
Imperative Languages
пЃ¬
Model of Computation
пЃ¬
ALU + Memory + Input + Output
(von Neumann architecture)
пЃ¬
Levels of Abstraction (“Human Interface”)
пЃ¬
Machine Language
пЃ¬
пЃ¬
Binary Representation of the task
Assembly Language
пЃ¬
Symbolic Representation of the task
Mark Hennessy Dept. Computer
Science NUIM CS351
Imperative Languages - FORTRAN
пЃ¬
Stands for FORmula TRANslantion.
 Invented in the 1950’s as the first high level
programming language i.e used a compiler.
пЃ¬ Hello World Example:
C
C
FORTRAN IV WAS ONE OF THE FIRST PROGRAMMING
LANGUAGES TO SUPPORT SOURCE COMMENTS
WRITE (6,7)
7 FORMAT(13H HELLO, WORLD)
STOP
END
Mark Hennessy Dept. Computer
Science NUIM CS351
Imperative Languages – ALGOL 60
пЃ¬
пЃ¬
Stands for ALGOrithmic Language
Defined in 1960 and was the first to introduce features
still in use today:
block structure and syntax defined by a grammar.
procedure Absmax(a) Size:(n, m) Result:(y) Subscripts:(i, k); value n,
m; array a; integer n, m, i, k; real y;
comment The absolute greatest element of the matrix a, of size n by m
is transferred to y, and the subscripts of this element to i and k;
begin integer p, q; y := 0; i := k := 1;
for p:=1 step 1 until n do
for q:=1 step 1 until m do
if abs(a[p, q]) > y then
begin y := abs(a[p, q]); i := p; k := q
end
end Absmax
Mark Hennessy Dept. Computer
Science NUIM CS351
Imperative Languages - C
пЃ¬
пЃ¬
пЃ¬
The most successful ALGOL type language.
Lexical variable scope and recursion
A static type system which prevents many
meaningless operations
пЃ¬ Function parameters are generally passed by
value (pass-by-reference is achieved in C by
explicitly passing pointer values)
пЃ¬ Heterogeneous aggregate data types (struct in
C) which allow related data elements to be
combined and manipulated as a unit
пЃ¬ A small set (around 30) of reserved keywords
Mark Hennessy Dept. Computer
Science NUIM CS351
Functional Languages
пЃ¬
Imperative programs are concerened with
programming a series of instructions that change the
state of program towards giving the solution.
пЃ¬ Functional Programming is concerned with viewing a
program as a series of mathematical functions.
пЃ¬ Based upon the maths model of Lambda Calculus,
developed by Turing, Church and Kleene in the
1930’s.
 Church’s thesis says that there is no one form of
computation that is any more powerful than another.
пЃ¬ This hold true as we are studying Paradigms!
Mark Hennessy Dept. Computer
Science NUIM CS351
Functional Languages
Turing developed a model of
computation called the Turing Machine
…. TCS course.
пЃ¬ Church developed lambda calculus.
пЃ¬ This is based on the notion of
parameterised expressions, which forms
the basis of Functional Programming.
пЃ¬ Passing arguments to methods.
пЃ¬
Mark Hennessy Dept. Computer
Science NUIM CS351
Functional Programming
пЃ¬
Introduced into programming the notions
of:
First class and higher order functions
пЃ¬ Polymorphism
пЃ¬ Lists
пЃ¬ Recursion
пЃ¬ Constructors
пЃ¬ Garbage Collection
пЃ¬
Mark Hennessy Dept. Computer
Science NUIM CS351
Functional Programming
пЃ¬
Difference between FP and Imperative
programming:
IP:
“To compute the gcd of a and b, check to see if a and b are equal.
If so print one of them and exit. Otherwise replace the larger one
by their difference and repeat.”
FP:
“The gcd of a and b is defined to be a when a=b, and to be the gcd of
c and d when a!=b, where c is the smaller of a and b and d is their
difference. To compute the gcd of a given pair of numbers, expand
and simplify this definition until it finishes.
Mark Hennessy Dept. Computer
Science NUIM CS351
Functional Languages - Lisp
пЃ¬
Stands for List Processing
пЃ¬ Same vintage as Fortran and ALGOL.
пЃ¬ Allows for operations on lists
пЃ¬
пЃ¬
пЃ¬
Eg car(0, 2, 4, 6) = 0
Eg cdr(0, 2, 4, 6) = (2, 4, 6)
Lisp Program for factorials:
(defun factorial (n)
(if (<= n 1)
1
(* n (factorial (- n 1)))))
Mark Hennessy Dept. Computer
Science NUIM CS351
Functional Languages - ML
Stands for Meta Language
пЃ¬ Functional Language with syntax closer
to what you are familiar with. Will be
doing practicals with it! (CaML).
пЃ¬ CaML Program for factorials.
пЃ¬
let rec fac n =
if n <= 1
then n
else n * fac(n-1);;
Mark Hennessy Dept. Computer
Science NUIM CS351
Logic Programming
Designed to allow mathematical axioms
help prove a theorem.
пЃ¬ Based on the idea of a Horn clause
пЃ¬
пЃ¬
H <- B1, B2,….Bn
The arrow means “if” and the commas
mean “and”
пЃ¬ We will be studying Logic programming
via Prolog
пЃ¬
Mark Hennessy Dept. Computer
Science NUIM CS351
Logic Programming - Prolog
пЃ¬
Name derives from the French programmation
en logique.
 Dates from the early 1970’s.
пЃ¬ Based upon Predicate Calculus, the system
uses backtracking.
Example Prolog Program for Factorials:
factorial(0,1).
factorial(N,F) :N>0,
N1 is N-1,
factorial(N1,F1),
F is N * F1.
Mark Hennessy Dept. Computer
Science NUIM CS351
Object Oriented Programming
Current paradigm. We write classes such
that data is hidden, ideas are abstracted
and code is re-usable! In theory….
пЃ¬ Simula -> Smalltalk & Ada -> C++ ->
Java
пЃ¬
пЃ¬
Sub paradigms
Aspect Oriented Programming
пЃ¬ Generic Programming via Templates
пЃ¬
пЃ¬
We will use C++ to show some
advanced OO features and generic
programming.
Mark Hennessy Dept. Computer
Science NUIM CS351
Scripting
Another form of programming is via
scripting.
пЃ¬ Huge amount of scripting languages,
Awk, sed, Bash, Javascript, UnrealScript
etc
пЃ¬ We will intoduce scripting via Bash and
Python in this course.
пЃ¬ Python uses dynamic typing and
features a very clean syntax. Multi
Paradigm!
пЃ¬
Mark Hennessy Dept. Computer
Science NUIM CS351
Scripting - Python
Indentation is essential!
пЃ¬ Sample factorial function:
пЃ¬
def fac ( num ):
if num == 1:
return 1
else :
return num * fac(num-1)
Mark Hennessy Dept. Computer
Science NUIM CS351
Документ
Категория
Презентации
Просмотров
17
Размер файла
115 Кб
Теги
1/--страниц
Пожаловаться на содержимое документа