4. Imperative programming
How it stared?
•Latin word “imperare” means to “to command”
•Machine languages of the original computers
•FORTRAN
•John Backus at IBM starting in 1954
•the first major programming language to remove the
obstacles presented by machine code .
5. Imperative programming
How it stated?
Fortran
compiled language
•Named variables
•Complex expressions
•Subprograms
•many other features now common in imperative languages.
7. Imperative Programming
•based on commands that update variables in storage.
•assignment changes the value at a location.
•a program execution generates a sequence of states.
13. getRemoteData(“example.com”, { data, error in
if error == nil {
parseData(data, { parsed, error in
if error == nil {
handleParsedData(parsed)
} else {
displayError(error)
}
})
} else {
dislpayError(error)
}
})
14. getRemoteData(“example.com”, { data, error in
if error == nil {
parseData(data, { parsed, error in
if error == nil {
if parsedDataValid(parsed) {
handleParseData(parsed)
} else {
displayError(error)
}
})
} else {
dislpayError(error)
}
})
15. getRemoteData(“example.com”, { data, error in
if error == nil {
parseData(data, { parsed, error in
if error == nil {
if ParsedDataValid(parsed) {
saveParsedDataIncache(parsed, { error in
if error == nil {
handleParseData(parsed)
} else {
displayError(error)
}
})
} else {
dislpayError(error)
}
})
16. getRemoteData(“example.com”, { data, error in
if error == nil {
parseData(data, { parsed, error in
if error == nil {
if ParsedDataValid(parsed) {
saveParsedDataInCache(parsed, { error in
if error == nil {
handleParseData(parsed), { error
in
if error == nil {
displaySuccess()
} else {
displayError(error)
}
})
} else {
17. Sample program of a imperative
using java programming
Java Code
SciCal.txt
18. functional programming
•Is when functions, not objects or procedures, are used as
the fundamental building blocks of a program.
•Abstraction and reducing complexity
•Lambda calculus
•Haskell
19. Functional programming
brief history
• Lambda calculus(Church and Rosser 1936)
• LISP(McCarthy 1960)
• Algol 60(Naure et al. 1963)
• ISWIM(Landin 1966)
• PAL(Evans 1968)
• SASL(Turner 1973-83)
• Development in Edinburgh(1969-80) –NPL, early ML, HOPE
• Miranda(1986)
• Haskell(1992)
20. Functional programming
HOW IT WORKS IN PL?
•Computations is carried out entirely through evaluation of
expressions.
•Emphasizes the composition and arrangement of functions,
often without specifying explicit steps
•Program correctness
•Shorter programs(lower lines to effect ratio)
23. 03/14/16
Sample program of a Functional
using Haskell Language
• ThreadScope is a tool for performance
profiling of parallel Haskell programs.
The ThreadScope program allows us to debug
the parallel performance of Haskell
programs. Using ThreadScope we can check
to see that work is well balanced across the
available processors and spot performance
issues relating to garbage collection or poor
load balancing.