visual programming languages ics 519 paradigms

23
Muhammed Al-Mulhem Visual Languages - 3 1 Visual Programming Languages ICS 519 Paradigms ICS Department KFUPM Feb. 1, 2005

Upload: conan

Post on 21-Jan-2016

45 views

Category:

Documents


0 download

DESCRIPTION

Visual Programming Languages ICS 519 Paradigms. ICS Department KFUPM Feb. 1, 2005. Paradigms. Imperative Languages: The features (Von Neumann architecture) are: Variables - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Visual Programming Languages ICS 519 Paradigms

Muhammed Al-Mulhem Visual Languages - 3 1

Visual Programming LanguagesICS 519

Paradigms

ICS Department

KFUPM

Feb. 1, 2005

Page 2: Visual Programming Languages ICS 519 Paradigms

Muhammed Al-Mulhem Visual Languages - 3 2

Paradigms

1) Imperative Languages:– The features (Von Neumann architecture) are:

• Variables• Assignment

• Control Structures

Page 3: Visual Programming Languages ICS 519 Paradigms

Muhammed Al-Mulhem Visual Languages - 3 3

Textual Example

main()

{

int i;

for ( i=0 ; i<10 ; ++i)

printf(" %d\n " , i);

}

Page 4: Visual Programming Languages ICS 519 Paradigms

Muhammed Al-Mulhem Visual Languages - 3 4

Visual Example• Pascal-

BLOX Language

Page 5: Visual Programming Languages ICS 519 Paradigms

Muhammed Al-Mulhem Visual Languages - 3 5

2) Functional (Applicative) Languages

– Function

– Atom

– List

– Recursion

Page 6: Visual Programming Languages ICS 519 Paradigms

Muhammed Al-Mulhem Visual Languages - 3 6

Textual Example

(DEFINE (equal list1 list2)

(COND

((ATOM? list1) (EQ? list1 list2))

((ATOM? List2) NIL)

((equal (CAR list1) (CAR list2))

(equal (CDR list1) (CDR list2)))

(ELSE NIL)

))

Page 7: Visual Programming Languages ICS 519 Paradigms

Muhammed Al-Mulhem Visual Languages - 3 7

Visual Example

• Clarity Language

Page 8: Visual Programming Languages ICS 519 Paradigms

Muhammed Al-Mulhem Visual Languages - 3 8

3) Object Oriented

– Class

– Object

– Message passing

Page 9: Visual Programming Languages ICS 519 Paradigms

Muhammed Al-Mulhem Visual Languages - 3 9

Textual Example

5 - 32

(3<5) ifTrue: [17]17

i ← 2[i<=9]whileTrue:[i print. i ← i + 3]258

Page 10: Visual Programming Languages ICS 519 Paradigms

Muhammed Al-Mulhem Visual Languages - 3 10

Visual Example

• Prograph is an example of a visual OOLs.• It has a visual representation for the

following OOP concepts:1. Classes2. Methods3. Parallelism4. Sequencing5. Iteration6. Conditional

• Look at the next figure.

Page 11: Visual Programming Languages ICS 519 Paradigms

Muhammed Al-Mulhem Visual Languages - 3 11

• Prograph Language

Page 12: Visual Programming Languages ICS 519 Paradigms

Muhammed Al-Mulhem Visual Languages - 3 12

4) Logic languages

– list

– predicate

– rule

– goal

Page 13: Visual Programming Languages ICS 519 Paradigms

Muhammed Al-Mulhem Visual Languages - 3 13

Example

• parent(X, Y) :- mother(X, Y).• parent(X, Y) :- father(X, Y).• grandparent(X, Z) :- parent(X, Y),parent(Y, Z).• parent(ali, ahmd).• parent(mohmd, ali).• grandparent(ahmd)

Page 14: Visual Programming Languages ICS 519 Paradigms

Muhammed Al-Mulhem Visual Languages - 3 14

Visual Example

Logic Languages

• Variable

• Constant

Page 15: Visual Programming Languages ICS 519 Paradigms

Muhammed Al-Mulhem Visual Languages - 3 15

• Predicate

q()

q(x) q(a,b)

q

q q

a b

Page 16: Visual Programming Languages ICS 519 Paradigms

Muhammed Al-Mulhem Visual Languages - 3 16

• Rule

• person(x):-mother(x,y),father(x,y)

person

mother father

Page 17: Visual Programming Languages ICS 519 Paradigms

Muhammed Al-Mulhem Visual Languages - 3 17

• program

person

Mother Father

person person ali

Page 18: Visual Programming Languages ICS 519 Paradigms

Muhammed Al-Mulhem Visual Languages - 3 18

5) Dataflow Languages• Programs are represented by a directed graph.

– Nodes– Arcs

• Johnston, Hanna, and Millar, “Advances in Dataflow Programming Language”, ACM Computing Survey, Vol. 36, No. 1, March 2004, pp.1-34.

Page 19: Visual Programming Languages ICS 519 Paradigms

Muhammed Al-Mulhem Visual Languages - 3 19

Pure Dataflow Model• Programs are represented by a directed graph.

• Nodes are primitive instructions such as arithmetic and comparison operations.

• Arcs represent the data dependencies between the instructions.

• Conceptually, data flows as tokens along the arcs which behave like unbounded first-in, first-out (FIFO) queues.

• Arcs that flow toward a node are said to be input arcs to that node, while those that flow away are said to be output arcs from that node.

Page 20: Visual Programming Languages ICS 519 Paradigms

Muhammed Al-Mulhem Visual Languages - 3 20

Pure Dataflow Model (Continue)

• When the program begins, special activation nodes place data onto certain key input arcs, triggering the rest of the program.

• Whenever a specific set of input arcs of a node (called a firing set) has data on it, the node is said to be fireable.

• A fireable node is executed at some undefined time after it becomes fireable. The result is that it removes a data token from each node in the firing set, performs its operation, and places a new data token on some or all of its output arcs.

• It then ceases execution and waits to become fireable again.

Page 21: Visual Programming Languages ICS 519 Paradigms

Muhammed Al-Mulhem Visual Languages - 3 21

Pure Dataflow Model (Continue)

• By this method, instructions are scheduled for execution as soon as their operands become available.

• This stands in contrast to the von Neumann execution model, in which an instruction is only executed when the program counter reaches it, regardless of whether or not it can be executed earlier than this.

• The key advantage is that, in dataflow, more than one instruction can be executed in parallel.

Page 22: Visual Programming Languages ICS 519 Paradigms

Muhammed Al-Mulhem Visual Languages - 3 22

Example

Page 23: Visual Programming Languages ICS 519 Paradigms

Muhammed Al-Mulhem Visual Languages - 3 23

• Under the von Neumann execution model, the program in Figure 1(a) would execute sequentially in three time units.

• Under the dataflow execution model, the program in Figure 1(b) would execute sequentially in two time units.

• It is clear that dataflow provides the potential to provide a substantial speed improvement by utilizing data dependencies to locate parallelism.