Escolar Documentos
Profissional Documentos
Cultura Documentos
Chapter No. 1
Imperative Languages
Model of computation based on a step by step sequences of commands. Program states exactly how the result is to be obtained. Destructive assignment of variables.
Functional Languages
A program in a functional language consists of a set of (possibly recursive) function definitions and expression whose value is output as the program's result. Functional languages are one kind of declarative language. Declarative languages allow the programmer to concentrate on the logic of an algorithm (declarative languages are goal driven,control is not the concern of the programmer)
Declarative Langauge
Model of computation based on a system where relationships are specified directly in terms of the constituents of the input data. Made up of sets of definitions or equations describing relations which specify what is to be computed, not how it is to be computed. Non-destructive assignment of variables. Order of execution does not matter (no side effects). Expressions/definitions can be used as values. Programmer no longer responsible for control.
Computational Model
Execution Model
Style
Method
Procedural Style
In a procedural style the algorithm for solving the problem is stated. A particular solution is then declared. (Imperative languages uses procedural style)
int nfac (int n) { int fac = 1; if (n > 0) for ( int i = 2; i <= n; i++ ) fac = fac * i; return fac; }
Procedural
Declarative
Declarative Style
Facts and relationships related to the problem have to be stated. Declarative Style
Declarative Style
Functional style relationships are expressed using functions. E.g. (square (n) (* n n)) This is a function square,that express the relationship between the input n and the output value n*n. Logic style relationships are declared using expressions known as clauses. E.g. square(N, M):M is N*N Clauses can be used to express both facts and rules.
Execution Model
Execution model consists of three components.
Execution Model
Declarative style
the problem description model states how the problem itself has to be described.
Execution Semantics
Execution Semantics
A rule that prescribes how a single execution step is to be performed. The rule is associated with the chosen problem description method and how the execution of the computation is interpreted.
Execution Semantics
Execution Model
State transition
semantics
Dataflow semantics
Reduction semantics
SLDresolution
Control Driven
Data Driven
Demand Driven
Control Driven
In control driven execution it is assumed there exist a program consisting of sequence of instructions. The execution sequence implicitly given by the order of the instructions Explicit control instructions can also be used to specify a departure from the implicit execution sequence.
Data Driven
It is characterized by the fact that an operation is activated as soon as the data is available. Also, known as eager evaluation.
Demand Driven
The operations will be activated only when their execution is needed to achieve the final result. Also known as lazy evaluation because the delayed until needed philosophy is applied.
Relationships Between the Concepts of Computational Model, Programming Language and the Architecture
Implementation tool
Computational model
Specification tool
Programming language
Computer architecture
Execution model
the computation is performed according to the given sequence of instructions. Instruction execution follows a state transition semantics and the model behaves just like finite state machine. Each instruction transfers the state of the machine to the present state to next one, in a definite way as specified by the semantics of the instruction.
Computational Model
Corresponding
architectures
Granularity Example
Granularity Low Language Class Conventional assembly language Conventional High language
High
Typing
Weekly type languages are LISP, FP. They are also know as untyped languages Typed architectures are commonly known as tagged. They provide a mechanism for typing the data being stored or processed, by extending the data word by tag. The tag contain the type identification and usually 35 bits long. Tagging bridge the gap between untyped architecture and weakly typed language