View
217
Download
0
Tags:
Embed Size (px)
Citation preview
1Muhammed Al-Mulhem Visual Languages
Visual Programming Languages
ICS 519Part 1
ICS Department
KFUPM
Sept. 15, 2002
2Muhammed Al-Mulhem Visual Languages
• Learning programming is a difficult task.
• Writing and testing a program is a difficult and time consuming task.
• The majority of computer users are non programmers.
• Programming languages are designed for professional programmers and computer scientists.
1Introduction
3Muhammed Al-Mulhem Visual Languages
• There are historical reasons for this lack of emphasis on human convenience in programming languages (Shu, 1988).
• The computer scientists, for the last fifty years, have concentrated on machine efficiency.
• Computing costs were high and human costs were relatively low.
• In the early years of computing, it was justifiable that efficiency took precedence over ease of programming.
4Muhammed Al-Mulhem Visual Languages
• With the decline in computing costs it is realized that it is the human resource that must be optimized.
• The challenge is to bring computer capabilities to people without special computer training.
• To meet the challenge a number of facilities have been introduced to ease the pain of programming and remembering commands.
• These facilities include icons, pointing devices, and menus.
5Muhammed Al-Mulhem Visual Languages
• Programming languages have evolved over the last fifty years from first generation programming languages to fourth generation programming languages.
• One characteristic of most of these languages is that they use one-dimensional and textual formats to represent programs.
• These formats are suitable for sequential machines but not for the multi-dimensional and visual human mind (Chang, 1986).
6Muhammed Al-Mulhem Visual Languages
• Visual programming is an attempt to simplify programming and to make better use of the human mind's capabilities
• George Raeder states "... human mind is strongly visually oriented and that people acquire information at a significantly higher rate by discovering graphical relationships in complex pictures than by reading text. ... When we scan paragraph, headlines, and material in bold type to speed up text search, we are really acting in the pictorial mode to overcome this limitation" (Raeder, 1985).
7Muhammed Al-Mulhem Visual Languages
• Visual programming represents a conceptually revolutionary departure from the traditional one-dimensional and textual programming languages.
It is stimulated by the following premises:
1) Pictures are more powerful than words as a means of communication. They can convey more meaning in a more concise unit of expression.
2) Pictures aid understanding and remembering.
3) Pictures may provide an incentives for learning program.
8Muhammed Al-Mulhem Visual Languages
4) Pictures do not have language barriers. When properly designed, they are understood by people regardless of what language they speak.
9Muhammed Al-Mulhem Visual Languages
• Visual programming has gained momentum in recent years.
• The falling costs of graphics-related hardware and software has made it feasible to use pictures as a means of communicating with the computers.
• Visual programming is a very young but growing field.
• There is no common agreement on the definition of visual programming.
10Muhammed Al-Mulhem Visual Languages
2Definitions
• Visual programming languages is a new paradigm.
• There is no single formal definition for VPL. For this reason we will present a number of definitions that appear in the literature.
11Muhammed Al-Mulhem Visual Languages
1) Chang, 1987
• Visual programming languages, usually deals with objects that do not have an inherent visual representation. This includes traditional data types such as arrays, stacks, and queues and application data types such as forms, documents, and databases. Presenting these objects visually is helpful to the user.
• For the same reason, the languages themselves should be represented visually.
• In other words, both programming constructs and the rules to combine these constructs should be presented visually.
12Muhammed Al-Mulhem Visual Languages
2) Shu, 1988
• A visual programming language can be informally defined as a language which uses some visual representations ( in addition to or in place of words and numbers) to accomplish what would otherwise have to be written in a traditional one-dimensional programming language.
• Note that this definition imposes no restrictions on the type of data or information.
– It is immaterial whether the object being operated on or being displayed to a user by a visual language is textual, numeric, pictorial, or even audio.
– What is important is that the language itself must employ some meaningful visual expressions as a means of programming.
13Muhammed Al-Mulhem Visual Languages
3) Tortora, 1990
• A visual language models an icon system. In the icon system, a program consists of a spatial arrangement of pictorial symbols ( elementary icons ).
• Note that, the spatial arrangement is the two-dimensional counterpart of the sequential statements in the traditional programming languages.
– In these languages, a program consists of a string in which terminals are concatenated.
– Concatenation is the only construction rule, therefore it doesn’t appear in the language grammar.
14Muhammed Al-Mulhem Visual Languages
• In the case of visual languages, three construction rules are used to spatially arrange icons:
– Horizontal concatenation.
– Vertical concatenation.
– Spatial overlay.
• For this reason, there is a need to include both spatial operators and elementary icons in the vocabulary of terminal symbols of the visual language grammar.
• Elementary icons are partitioned into two categories:
– Object icons which identify objects.
– Process icons which express computation.
15Muhammed Al-Mulhem Visual Languages
4) Al-Mulhem, 1993
• Visual programming languages is a language which uses a combination of text and meaningful graphical symbols to write programs. These graphical/textual symbols represent the following:
a) Data types such as numbers, characters, pictures, and sound.
b) Data structures such as arrays, records, and pointers.
c) Programming constructs such as iteration, selection, and conditional looping.
d) Rules to combine the programming constructs.
16Muhammed Al-Mulhem Visual Languages
5) Burnett (1999)
• Visual programming is programming in which more than one dimension is used to convey semantics.
• Examples of such additional dimensions are the use of multi-dimensional objects, the use of spatial relationships, or the use of the time dimension to specify “before-after” semantic relationships.
• Each potentially-significant multi-dimensional object or relationship is a token (just as in traditional textual programming languages each word is a token) and the collection of one or more such tokens is a visual expression.
17Muhammed Al-Mulhem Visual Languages
• Examples of visual expressions used in visual programming include diagrams, free-hand sketches, icons, or demonstrations of actions performed by graphical objects.
• When a programming language’s (semantically-significant) syntax includes visual expressions, the programming language is a visual programming language (VPL).
18Muhammed Al-Mulhem Visual Languages
VPL Research
• Directions of research in this area are:
1. Visual approaches to traditional programming languages (flowchart).
2. Visual approaches that deviated from traditional programming (programming by demonstration).
19Muhammed Al-Mulhem Visual Languages
How good are they?
• Good for toy programs.
• Bad for realistically-sized programs.
20Muhammed Al-Mulhem Visual Languages
More approaches
• Incorporating visual techniques into programming environments:
• To support textual specification of GUI layout
• To support electronic forms of software engineering diagrams.
• To create/visualize relationships among data structures.
• To visually combine textually-programmed units to build new programs.
21Muhammed Al-Mulhem Visual Languages
Examples
• Visual Basic (for BASIC)
• VisualWork (for SmallTalk)
• CASE tools that support visual specificatio of relationships among program modules, automatic code generation, …etc.
22Muhammed Al-Mulhem Visual Languages
23Muhammed Al-Mulhem Visual Languages
More approaches
• Domain-specific visual programming systems
• Examples:
1. LabVIEW – programming laboratory data acquestion.
2. AVS – programming Scientific Visualization
3. PhonePro – programming telephone and voice-mail behavior.
4. Cocoa – programming graphical simulations and games.
24Muhammed Al-Mulhem Visual Languages
What is next?
• VPLs for general-purpose programming.
• This can be reached by:
1. Improving the ways VP can be used.
2. Improving domain-specific programming
25Muhammed Al-Mulhem Visual Languages
Strategies used in VPLs
• Concrete: specify some aspect of semantics on a specific object or value.
• Direct: manipulate a specific object or value directly to specify semantics.
• Explicit: describe dataflow relationships by drawing directed edges among related variables.
• Immediate visual feedback: automatic display of effects of program edits.
26Muhammed Al-Mulhem Visual Languages
Classification
1. Pure visual programming
2. Hybrid (textual / visual) programming
3. Programming-by-example
4. Constraint-based programming
5. Form-based programming
27Muhammed Al-Mulhem Visual Languages
Pure visual programming
• Programmer manipulate icons to create a program.
• A program is debugged and executed in the same visual environment.
• A program is compiled directly from its visual representation.
• A program is never translated into intermediate text-based language.
• Examples: Prograph, VIPR, and PICT.
28Muhammed Al-Mulhem Visual Languages
Hybrid (textual / visual) programming
• Two forms:
1. Systems in which programs are created visually and then translated into an underlying high-level textual languages.
• Example: Rehearsal World – the user trains the system to solve a particular problem by manipulating graphical actors (icons) and then the system generates a Smalltalk program to implement the solution.
29Muhammed Al-Mulhem Visual Languages
Hybrid (continue)
2. Systems which involve the use of graphical elements in a textual language.
• Example: Work of Erwig et. al. – developing extensions to languages like C and C++ which allow programmers to mix their text code with diagrams.
• For instance, one can define a linked list data structure textually and then perform an operation like deletion of a node by drawing the steps in the process.
30Muhammed Al-Mulhem Visual Languages
Programming by example
• Allowing the user to create and manipulate graphical objects with which to teach the system how to perform a particular task.
• Examples: Rehearsal World and Pygmalion
31Muhammed Al-Mulhem Visual Languages
Constraint-oriented programming
• A programmer models physical objects as objects in the visual environment which are subject to constraints designed to mimic the behavior of natural laws, like gravity.
• Popular for simulation design.
• Examples: ThingLab, ARK
32Muhammed Al-Mulhem Visual Languages
Form-based programming
• Borrowed their visualizations and programming metaphors from a spreadsheets.
• Represent programming as altering a group of interconnected cells over time and often allow the programmer to visualize the execution of a program as a sequence of different cell states which progress through time.
• Example: Forms/3
33Muhammed Al-Mulhem Visual Languages
VPL Orphans
• Algorithm animation systems
• Provides interactive graphical displays of executing programs
• Example: BALSA
• user-interface design systems
• Provided with many modern compilers.
• Example: Visual Basic, Visual C++
34Muhammed Al-Mulhem Visual Languages
Theory• Based on work by Chang• Definitions• Icon (generalized icon): An object with the dual
representation of: – logical part (the meaning)– Physical part (the image)
• iconic system: structured set of related icons
• iconic sentence (visual sentence): spatial arrangement of icons from iconic system
35Muhammed Al-Mulhem Visual Languages
Theory (con.)
• visual language: set of iconic sentences constructed with given syntax and semantics
• syntactic analysis (spatial parsing): analysis of an iconic sentence to determine the underlying structure
• semantic analysis (spatial interpretation): analysis of an iconic sentence to determine the underlying meaning
36Muhammed Al-Mulhem Visual Languages
Theory (con.)
• A visual Language Models an Icon System.
• In the Icon System, a program (Visual Sentence) consists of a spatial arrangement of pictorial symbols (elementary icons).
• The spatial arrangement is the two-dimensional counterpart of the standard sequentialization in the construction of programs in the case of traditional programming languages.
37Muhammed Al-Mulhem Visual Languages
• In traditional languages, a program is expressed by a string in which terminals are concatenated.
• As this operation (concatenation) is the only construction rule, it does not appear explicitly in the vocabulary of the language grammar.
• In the case of visual languages, three construction rules are used to spatially arrange icons:
– Horizontal concatenation &
– Vertical concatenation ^
– Spatial overlay +
38Muhammed Al-Mulhem Visual Languages
• For this reason, there is a need to include the spatial operators and elementary icons in the vocabulary of terminals of the visual language grammar.
• The elementary icons are partitioned into:– object icons
– process icons.
• Elementary object icons identify objects while process icons express computations.
• The meaning depends on the specific visual sentence in which it appears.
39Muhammed Al-Mulhem Visual Languages
Example
• Consider the following primitive icons from the Heidelberg icon set.
where
• the square denotes a character, and its interpretation is unique in the system.
• the arrow can be used to express insertion or moving operations in different visual sentences.
40Muhammed Al-Mulhem Visual Languages
• A Visual Language (VL) is specified by the triple
» (ID, Go, B)
where
• ID is the icon dictionary
• Go is a context-free grammar
• B is a domain-specific knowledge base.
41Muhammed Al-Mulhem Visual Languages
The icon dictionary ID
• It is a set of triples of the form
» i = (il , ip , type(i))
• Each triple i describes a primitive icon where
– il is the icon name (logical part or meaning)
– ip is the icon sketch (physical part)
– type(i) is the icon type (process or object)
42Muhammed Al-Mulhem Visual Languages
The grammar Go
• It is a context-free grammar (N, T, S, P).
Where
• N is the set of nonterminals
• T = Tl U Tsp
• Tl = { il | i = ( il, ip, type(i)) ID}
• Tsp = { &, ^, + }
• S is the start symbol of the grammar
• P is the set of productions of Go
43Muhammed Al-Mulhem Visual Languages
• The grammar Go specifies how more complex icons can be constructed by spatially arranging elementary icons.
• Usually, nonterminals in Go & the start symbol represent composite object icons.
• Composite object icons can be derived in one or more steps starting from a given nonterminals, N, which is different from S.
• In other words, composite object icons are obtained by spatial arrangement of elementary object icons only and are assumed to be of type object.
44Muhammed Al-Mulhem Visual Languages
• Visual Sentences contain at least one process icon.
• Visual Sentences have no type.
• Here, object icons denote both elementary object icons & composite object icons.
• It is easy to prove that all the icons involved in the icon system (elementary object, composite object, and visual sentences) are objects with dual representation of a logical and a physical part as follows:
45Muhammed Al-Mulhem Visual Languages
• Elementary object --- by definition in ID.
• Composite object and visual sentences ---– The physical part is their image
– The logical part (the meaning) can be derived from the meaning of the elementary objects occurring in them.
• The meaning of a visual sentence is expressed in terms of a conceptual tree, which represents an intermediate code for later execution.
46Muhammed Al-Mulhem Visual Languages
Conceptual Trees
• The meaning of a visual sentence is expressed in terms of a conceptual tree (CT), which represents an intermediate code for later execution.
• In CT notations a concept is denoted by [ ], and a relation is denoted by ( ).
47Muhammed Al-Mulhem Visual Languages
The concepts are expressed in the form
[ OBJECT : object-name]
[ EVENT : event-name]
where
• object-name represents the logical part (meaning) of an object icon (elementary icon or composite object icon)
• event-name are event names, i.e., procedure names, which accomplish the task expressed by the visual sentence
48Muhammed Al-Mulhem Visual Languages
• The following CTs are basic substructures occuring in all the CTs which represent the logical part of a visual sentence.
[EVENT: event-name] (rel1) [OBJECT: object-name1]
(rel2) [OBJECT: object-name2] (1)
[EVENT: event-name] (rel) [OBJECT: object-name] (2)
[OBJECT: object-name] (rel) [OBJECT: object-name] (3)
The meanings of these CTs are as follows:
49Muhammed Al-Mulhem Visual Languages
• 1) A process icon has two object icons as arguments
Example:
consider the following icon from the Heidelberg icon set
50Muhammed Al-Mulhem Visual Languages
• It is composed of the object icons
• Selected-string
• String
• and the process icon Up-arrow
51Muhammed Al-Mulhem Visual Languages
• Its meaning is expressed by the CT
[EVENT: replace] (object) [OBJECT: String]
(place) [OBJECT: Selected-string]
52Muhammed Al-Mulhem Visual Languages
2) A process icon requires only one argument.
Example:
53Muhammed Al-Mulhem Visual Languages
• It is obtained by composing in spatial overlay:
• the object icon Selected-string
• and the process icon cross
54Muhammed Al-Mulhem Visual Languages
• Its meaning is described by the CT
[EVENT: delete] (object) [OBJECT: Selected-string]
55Muhammed Al-Mulhem Visual Languages
3) Here we have two combined object icons. This is the case in which one of the two objects involved in the visual sentence represents a qualitative or quantitative specification of the other object.
Example:
The object "name” identifies the object "file"
File nameFile name
56Muhammed Al-Mulhem Visual Languages
The meaning is
[OBJECT: file] (identifier) [OBJECT: name]
57Muhammed Al-Mulhem Visual Languages
• Complex structures can be obtained by composing the basic substructures as shown below:
1 2 3
This visual sentence could mean: append file1 to file2 and copy the result into file3
58Muhammed Al-Mulhem Visual Languages
• The sentence could be decomposed into two subsentences:
1 2
and
2 3
59Muhammed Al-Mulhem Visual Languages
• These subsentences are described, respectively, by the following CTs
[EVENT: append] (object) [OBJECT: file1]
(place) [OBJECT: file2]
[EVENT: copy] (source) [OBJECT: file2]
(destination) [OBJECT: file3]
60Muhammed Al-Mulhem Visual Languages
The whole visual sentence is described by
[EVENT: copy] (destination) [OBJECT: file3]
(source) [EVENT: append]
(object) [OBJECT: file1]
(object) [OBJECT: file2]
61Muhammed Al-Mulhem Visual Languages
The Knowledge Base B• The Knowledge Base B contains domain-specific
information necessary for constructing the meaning of a given visual sentence.
• It contains information regarding» Event names
» Conceptual relations
» Names of the resulting objects
» References to the resulting objects.
62Muhammed Al-Mulhem Visual Languages
It is structured in the following seven tables:1) EVENT-NAME [proc-name, obj-name1, obj-name2, op1, op2] This
table returns the name of the event (procedure) to be associated to the process icon proc-name when the objects obj-name1, obj-name2 are spatially arranged (via op1, op2) to proc-name.
2)LEFT-REL [proc-name, obj-name1, obj-name2, op1, op2]
3)RIGHT-REL [proc-name, obj-name1, obj-name2, op1, op2]
These two tables hold the conceptual relations existing between EVENT-NAME [Proc-name, obj-name, obj-name2, op1, op2] and obj-name1 or obj-name2 respectively.
63Muhammed Al-Mulhem Visual Languages
4)RESULT-NAME [Proc-name, obj-name1, obj-name2, op1, op2]
This table returns the name of the object resulting from the execution of the event.
EVENT-NAME [Proc-name, obj-name1, obj-name2, op1, op2]. With arguments obj-name1 and obj-name2.
5)RESULT-REF [Proc-name, obj-name1, obj-name2, op1, op2].
This table returns a reference to the object representing the result.
64Muhammed Al-Mulhem Visual Languages
The following two tables take into account cases in which object icons are composed (composite object icons).
6) RELATION [obj-name1, obj-name2, op].
This returns the conceptual relation existing between obj-name1 and obj-name2 when they are spatially combined by means of the operator op.
7)RESULT-OBJECT [obj-name1, obj-name2, op].
This returns the name of the object resulting by the spatial combination (via op) of obj-name1 and obj-name2.
In the previous tables, obj-namei refer to the logical part of the icons.
65Muhammed Al-Mulhem Visual Languages
• Besides domain-specific relations the tables can also contain three special relations:
<new> :This relation means that the combination
obj-name1 op obj-name2
gives rise to a new object, different from obj-name1 and obj-name2.
<null>:This relation means that the combination
obj-name1 op obj-name2
generates an object that has the same logical part of the obj-name1 or obj-name2.
In other words, it points out that no additional information is derived from such a combination.
66Muhammed Al-Mulhem Visual Languages
<l-obj> , <r-obj>:
These two relations mean that the combination
obj-name1 op1 proc-name op2 obj-name2
generates an object that has the same reference of the icon whose name is obj-name1 or obj-name2 respectively.
67Muhammed Al-Mulhem Visual Languages
file2 file3
Obj-name1Obj-name1
Op1=&Op1=&
Proc-nameProc-name Op2=&Op2=& Obj-name2Obj-name2
68Muhammed Al-Mulhem Visual Languages
Table 1: returns the name of the event “copy”
Table 2, 3:
LEFT-REL
[EVENT: copy] (source) [OBJECT: file2]
(destination) [OBJECT: file3]
RIGHT-REL
69Muhammed Al-Mulhem Visual Languages
Table 4: Return file 3
Table 5: Return a reference (pointer) file3
Table 6:
[OBJECT: file] (identifier) [OBJECT: file3]
returns this
Table 7: Return the name of the resulting object in 6
70Muhammed Al-Mulhem Visual Languages
The Attribute Grammar • An attribute grammar consists of a semantics
rules for synthesizing the meaning of a visual sentence
• AG consists of an underlying context-free grammar where
i) each nonterminal in the context-free grammar has associated two attribute sets, namely, synthesized and inherited attributes.
71Muhammed Al-Mulhem Visual Languages
ii) each production has associated a set of semantics rules, used to determine the values of the attributes of the nonterminals depending on the values of the attributes of the remaining nonterminals appearing in the same production.
• The initial nonterminal has only synthesized attributes, and one of them is designated to hold the meaning of the derivation tree.
72Muhammed Al-Mulhem Visual Languages
The production rules in Go are of the following form:
a) X t t T
b) X Y where type (X) = type (Y)
c) X M op L | L op M | M1 op M2
d) X M1 op1 L op2 M2
where
• type (L) = PROCESS
• type (M) = type (M1) = type (M2) = OBJECT.
• op, op1, op2 = nonterminals for spatial operators ( &, * , +)
73Muhammed Al-Mulhem Visual Languages
• The type for a given nonterminal X is determined as follows:
Let
X t be a derivation in Go and t T*
Then type (X) = spatial operator if t Tsp
type (X) = type (t) otherwise.
• The set of inherited attributes is empty for each nonterminal in Go.
74Muhammed Al-Mulhem Visual Languages
• The set of synthesized attributes associated to each nonterminal X is defined as follows.
• For a given non-terminal X
1. if type (X) = OBJECT :
NAME (X) is the name of the object icon represented by X.
CG(X) is the CT associated to the subtree rooted in X.
REF(X) is the reference number. The reference number is an index associated with each elementary object icon occurring in a visual sentence. It allows one to distinguish between different occurrences of the same elementary object icon in a visual sentence.
75Muhammed Al-Mulhem Visual Languages
2. if type (X) = PROCESS:
NAME(X) is the name of the process icon represented by X.
3. if type (X) : "spatial operator" :
OP(X) is the spatial operator derived from X.
76Muhammed Al-Mulhem Visual Languages
• The semantic rules associated with the four production rules are:
a) X t
a1) If t = icon-id
where
( icon-id, icon-sk, type( i ) ) ID and
type ( i ) = OBJECT (i.e. t is a terminal for an elementary icon).
Then
NAME(X) icon-id
REF (X) ref-set
CG (X) [OBJECT : NAME(X), REF(X)]
77Muhammed Al-Mulhem Visual Languages
a2) If t = icon-id
where
( icon-id, icon-sk, type( i ) ) ID and
type ( i ) = PROCESS
Then
NAME(X) t
a3) If t {&, L , +}
Then
OP(X) t
78Muhammed Al-Mulhem Visual Languages
b) X Y
b1) If type (Y) = OBJECT
Then
NAME(X) NAME (Y)
REF (X) REF (Y)
CG (X) CG (Y)
b2) If type (Y) = PROCESS
Then
NAME(X) NAME (Y)
b3) If Y op and op {&, L , +}
Then
OP(X) OP(Y)
79Muhammed Al-Mulhem Visual Languages
c) X M op L
c1) If type (M) = OBJECT and type (L) = PROCESS
Then
NAME(X) RESULT-NAME [NAME(L), NAME (M), ‘null-obj’, op(op),
‘null-op’]
REF(X) SET-REF (L, M, ‘null-obj’, op, ‘null-op’)
CG (X) SELECTIVE-MERGE (L, M, ‘null-obj’, op, ‘null-op’)
80Muhammed Al-Mulhem Visual Languages
c2) If type (M) = PROCESS and type (L) = OBJECT
Then
NAME (X) RESULT-NAME [NAME(M), ‘null-obj’, NAME(L), ‘null-op’, OP(op)]
REF(X) SET-REF (M, ‘null-obj’, L, ‘null-op’ , op)
CG (X) SELECTIVE-MERGE (M, ‘null-obj’, L, ‘null-op’, op)
81Muhammed Al-Mulhem Visual Languages
c3) If type (M) = type (L) = OBJECT
Then
NAME (X) RESULT-OBJECT [NAME (M), NAME(L), OP(op)]
REF(X) REF (M) U REF (L)
CG (X) LINK (X, M, L, op)
82Muhammed Al-Mulhem Visual Languages
d) X M1 op1 L op2 M2
If type (L) = PROCESS and
type (M1) = type (M2) = OBJECT
Then
NAME (X) RESULT-NAME [NAME (L), NAME(M1), NAME (M2), OP(op1), OP (op2)]
REF(X) SET-REF (L, M1, M2, op1, op2)
CG (X) SELECTIVE-MERGE (L, M1, M2, op1, op2)
83Muhammed Al-Mulhem Visual Languages
• Semantic rules c and d make use of the following procedures:
Procedure LINK (X, M1, M2, op)
rel RELATION [NAME(M1), NAME (M2), OP(op)]
case rel of
<new> : if NAME (X) ID then
- add the new composite object NAME(X) to ID
- return [OBJECT: NAME (X), REF(X)]
endif
<null> : return CG(M1)
else : return APPEND (CG(M1), CG(M2), rel)
end case
end LINK
84Muhammed Al-Mulhem Visual Languages
Procedure SELECTIVE-MERGE (L, M1, M2, op1, op2)
C [EVENT:EVENT-NAME [NAME(L),
NAME(M1), NAME(M2), OP(op1), OP(op2)]
if OP(op1) = ‘null-op’ then G1 C
else rel1 LEFT-REL [NAME(L), NAME(M1),
NAME (M2), OP(op1), OP(op2)]
G1 APPEND (C, CG(M1), rel1)
endif
if OP(op2) = ‘null-op’ then G2 C
else rel2 RIGHT-REL [NAME(L), NAME(M1),
NAME (M2), OP(op1), OP(op2)]
G2 APPEND (C, CG(M2), rel2)
endif
return HEADER-MERGE (G1, G2)
end SELECTIVE-MERGE
85Muhammed Al-Mulhem Visual Languages
Procedure SET-REF (L, M1, M2, op1, op2)
ref RESULT-REF [NAME(L), NAME(M1), NAME (M2), OP(op1), OP(op2)]
case ref of
<l-obj> : return REF(M1)
<r-obj> : return REF(M2)
<new-obj>: return NEXT-REF( )
end case
end SET-REF
86Muhammed Al-Mulhem Visual Languages
The Icon Interpreter:
• The system diagram of the icon interpreter is as follows:
G0 BID
PatternAnalysis
SyntaxAnalysis
Construction of theLogical part
Visual Sentencce S
Pattern String of SParse Tree of S
Meaning of SCG
87Muhammed Al-Mulhem Visual Languages
• The module ”Pattern Analysis" transforms the visual sentence into pattern string .
Example
• The visual sentence
• is represented by the pattern string
(char & char & char) + cross
88Muhammed Al-Mulhem Visual Languages
• The icon interpreter is logically divided into two phases:
1.The syntax analysis is accomplished by a parsing algorithm for context-free grammars.
2.Constructing the meaning of the given visual sentence by evaluating the attributes of the nonterminal on the root of the parse tree using the ATTRIBUTE_EVALUATOR procedure
• The attribute evaluation is accomplished by means of a postorder visit of the parse tree t of the visual sentence S
89Muhammed Al-Mulhem Visual Languages
Procedure ATTRIBUTE-EVALUATOR (X).
if X is a nonterminal in Go
then /* let p be the production applied to the node X in t, and let 1, ..., np be the indices of nonterminals in the right-hand side of p*/
for j = 1 to np do
call ATTRIBUTE-EVALUATOR (jth nonterminal son of X in t)
end for
apply the semantic rules associated to p so as to evaluate the attributes of X
endif
end ATTRIBUTE-EVALUATOR
90Muhammed Al-Mulhem Visual Languages
Example
• This example shows an iconic command language for simple operating system.
• The set of elementary icons ID and the grammar G0, are shown in the following slides.
91Muhammed Al-Mulhem Visual Languages
92Muhammed Al-Mulhem Visual Languages
93Muhammed Al-Mulhem Visual Languages
• The knowledge base B is given next.
• Each entry in the tables, which constitute the knowledge base, contains five items, which correspond, from top to bottom, to the tables:
– EVENT_NAME
– LEFT_REL
– RIGHT_REL
– RESULT_NAME
– RESULT_REF
94Muhammed Al-Mulhem Visual Languages
95Muhammed Al-Mulhem Visual Languages
• Consider the following visual sentence:
• Whose corresponding pattern string is
[FILE,1] & PLUS & [FILE,2] & ARROW&[FILE,3]
• The parse tree for this sentence is shown next.
96Muhammed Al-Mulhem Visual Languages
97Muhammed Al-Mulhem Visual Languages
• The construction of the conceptual tree is given in the next table. At level 1, the resulting conceptual tree is given by:
[EVENT: copy] (destination) [OBJECT: file3]
(source) [EVENT: append]
(object) [OBJECT: file1]
(object) [OBJECT: file2]
98Muhammed Al-Mulhem Visual Languages
Examples of VPLs
• Prograph (1989) – Dataflow programming
• DataLab (1990) – Programming by example
• Form/3 (1994) – Form-based programming
• Clarity (2001) – Functional programming
99Muhammed Al-Mulhem Visual Languages
Prograph
• The Prograph language is an iconic language.
• Program is drawings.
• Prograph interpreter and compiler execute those drawings.
• Prograph is object-oriented
• Prograph supports dataflow specification of program execution
100Muhammed Al-Mulhem Visual Languages
Simple program
• A simple Prograph code which sorts, possibly in parallel, three database indices and updates the database.
101Muhammed Al-Mulhem Visual Languages
Paragraph’s icons
• Prograph uses a set of icons:
• classes are represented by hexagons,
• data elements by triangles,
• pieces of code by rectangles with a small picture of data flow code inside, and
• inheritance by lines or downward pointing arrows.
102Muhammed Al-Mulhem Visual Languages
103Muhammed Al-Mulhem Visual Languages
More Icons
• The representations can then be combined and used in a variety of language elements.
• For example, initialization methods - which are associated with an individual class - are depicted as hexagonally shaped icons with a small picture of data flow code inside.
104Muhammed Al-Mulhem Visual Languages
Icon (C0nt.)
• Triangles represent instance variables in a class’ Data Window to show that they’re data.
• Hexagons drawn with edges and interiors similar to the instance variable triangles represent class variables. This associates them with the class as a whole while also associating them with data.
• Next Figure shows three more complex representations: initialization methods , instance variables, and class variables.
105Muhammed Al-Mulhem Visual Languages
Icon (Cont.)
106Muhammed Al-Mulhem Visual Languages
Object-Oriented
• The Prograph language is object-oriented.
• Class-based,
• Single inheritance (a subclass can only inherit from one parent),
• Dynamic typing
• With garbage collection mechanism based on reference counting.
107Muhammed Al-Mulhem Visual Languages
Cont.
• The programmer can design and implement new classes,
• He can visually specifying:
– the new class’ inheritance,
– additional instance or class variables,
– modified default values for inherited instance or class variables,
– and new or overridden methods.
108Muhammed Al-Mulhem Visual Languages
Cont.
• Polymorphism allows each object to respond to a method call with its own method appropriate to its class.
• Binding of a polymorphic operation to a method in a particular class happens at run-time, and depends upon the class of the object.
• The syntax for this ‘message send’ is one of the more unusual aspects of Prograph’s syntax.
• The concept of ‘message sending’ per se is not used in Prograph.
109Muhammed Al-Mulhem Visual Languages
Annotation
• Rather, the idea of an annotation on the name of an operation is used. There are four cases:
1. No annotation means that the operation is not polymorphic.
2. ‘/’ denotes that the operation is polymorphic and is to be resolved by method lookup starting with the class of the object flowing into the operation on its first input
110Muhammed Al-Mulhem Visual Languages
Annotation (Cont.)
3. ‘//’ denotes that the operation is polymorphic and is to be resolved by method lookup starting with the class in which this method is defined.
4. ‘//’ plus super annotation means that the operation is polymorphic and resolves by method lookup starting with the superclass of the class in which this method is defined.
• In Prograph there is no SELF construct (or a ‘this’ construct, to use the C++ terminology).
111Muhammed Al-Mulhem Visual Languages
• Prograph has an almost completely iconic syntax, and this iconic syntax is the only representation of Prograph code.
• Next Figure shows a small code fragment typical of the Prograph language.
• There is no textual equivalent of a piece of a
Prograph program - the Prograph interpreter and compiler translate directly from this graphical syntax into code.
112Muhammed Al-Mulhem Visual Languages
Example
113Muhammed Al-Mulhem Visual Languages
Icons
• Next Figure shows most of the lexicon of the language (icons).
• The inputs and outputs to an operation are specified by small circles at the top and bottom, respectively, of the icons.
• The number of inputs and outputs - the operation’s arity - is enforced only at run-time.
• In addition, there are a variety of annotations that can be applied to the inputs and outputs, or to the operation as a whole to implement looping or control flow.
114Muhammed Al-Mulhem Visual Languages
115Muhammed Al-Mulhem Visual Languages
Spaghetti Code
• Visual languages like Prograph sometimes suffer from the spaghetti code problem: there are so many lines running all over that the code for any meaningful piece of work actually ends up looking like spaghetti.
• Prograph deals with this issue by enabling the programmer to ‘iconify’ any portion of any piece of code at any time during the development process.
116Muhammed Al-Mulhem Visual Languages
Local
• This iconified code is called a ‘local’.
• Effectively, locals are nested pieces of code.
• There is no limit to the level of nesting possible with locals, and there is no execution penalty to their use.
• In addition, locals can be named and this naming, if done well, can provide a useful documentation for the code.
117Muhammed Al-Mulhem Visual Languages
Example
• Next Figure is a code to build a dialog box containing a scrolling list of the installed fonts without the use of Prograph locals to factor the code.
118Muhammed Al-Mulhem Visual Languages
119Muhammed Al-Mulhem Visual Languages
Same Example
• Next Figure is the same code with the use of Prograph locals to factor the code.
120Muhammed Al-Mulhem Visual Languages
121Muhammed Al-Mulhem Visual Languages
Local (Cont.)
• Note that long names, often containing punctuation or other special characters can be used for the names of locals.
• The proper use of locals can dramatically improve the comprehensibility of a piece of code.
• The one negative aspect of their use is the so-
called “rat hole” phenomena - every piece of code in its own rat hole. This can sometimes make finding code difficult.
122Muhammed Al-Mulhem Visual Languages
Syntax
• Three of the most interesting aspects of the Prograph syntax are:
– list annotation,
– injects, and – control annotation.
123Muhammed Al-Mulhem Visual Languages
List Annotation
• Any elementary operation can be made to loop by list annotating any of its inputs.
• When this is done, the operation is invoked multiple times - one time for each element of the list that is passed on this input.
• Thus, list annotation on an input causes the compiler to construct a loop for the programmer. Since this annotation can be made on a local as well as a primitive operation, this looping construct is quite powerful.
124Muhammed Al-Mulhem Visual Languages
List Annotation (Cont.)
• In addition, list annotation can be done on a output.
• On an output terminal, list annotation causes the system to put together all the outputs at this terminal for every iteration of the operation and to pass as the ‘final’ output of the terminal this collection of results as an output list.
125Muhammed Al-Mulhem Visual Languages
List Annotation (Cont.)
• List annotation, then, enables the programmer to easily make an operation into a loop that either breaks down a list into its component elements and runs that operation on the elements, or to builds up a list from the multiple executions of an operation.
• An individual operation can have any number of its inputs or outputs with list annotations.
126Muhammed Al-Mulhem Visual Languages
List Annotation (Cont.)
• Next Figure shows several examples of list annotation, an efficient mechanism for iterating over a list.
• The operation will automatically be called repeatedly for each element of a list, or its outputs will be packaged together into a list.
127Muhammed Al-Mulhem Visual Languages
128Muhammed Al-Mulhem Visual Languages
129Muhammed Al-Mulhem Visual Languages
130Muhammed Al-Mulhem Visual Languages
Inject
• Inject lets you pass a name at run-time for an input which expects a function.
• This is similar to Smalltalk’s perform, procedure variables in Pascal or function pointers in C.
• Suppose, for example, that you want to implement a function FooMe that takes two arguments: a list of objects, and a reference to a method to be applied to each of those objects.
131Muhammed Al-Mulhem Visual Languages
Inject (Cont.)
• In Object Pascal pseudo-code, this function might look something like this:
Function FooMe(theList: TList; Procedure DoThis(object: TObject));
{ Iterates through the list of objects applying the DoThis procedure }
BEGIN
theList.Each(DoThis);
END;
132Muhammed Al-Mulhem Visual Languages
• Next Figure shows a Prograph implementation of FooMe.
• Note that just the name - as a string - of the method to be applied to each object is passed to FooMe.
• This string is turned into a method invocation by the inject.
133Muhammed Al-Mulhem Visual Languages
134Muhammed Al-Mulhem Visual Languages
Inject (Cont.)
• The Prograph representation of inject - a nameless operation with one terminal descending into the operation’s icon - is a particularly well-designed graphic representation for this programming concept.
• When properly used, inject can result in extremely powerful and compact Prograph implementations of complex functions.
• However, when used improperly, it can result in code that is very difficult to read or debug, like the computed GOTO of FORTRAN.
135Muhammed Al-Mulhem Visual Languages
Control Flow
• Control flow is a combination of annotations on operations and a case structure.
• A Prograph method can consist of a number of mutually exclusive cases. These cases are somewhat similar to the cases in a Pascal CASE statement or a C switch expression.
• The main difference is that unlike Pascal or C, the code to determine which case will be executed is inside the case, not outside it.
136Muhammed Al-Mulhem Visual Languages
Example
• Suppose that we want to implement a small function that has one integer input, and
• if that input is between 1 and 10, the value of the function is computed one way;
• if it is between 11 and 100, another way, and
• if it is anything else, yet a third way.
• In Pascal-like pseudo-code, this function would look something like this:
137Muhammed Al-Mulhem Visual Languages
Function Foo( i: Integer): Integer;
Begin
Case i of
1..10: Foo := Calculation_A(i);
11..100: Foo := Calculation_B(i);
OtherwiseFoo := Calculation_C(i);
End; {Case}
End; {Foo}
138Muhammed Al-Mulhem Visual Languages
Control Flow (Cont.)
• The implementation of Foo in Prograph would also involve three cases, as shown in the next Figure.
• The control annotations are the small boxes on the right of the match primitives at the top of the first two cases. (Note that the window titles show the total number of cases in a method, and which case this window is, as in “2:3” the second of three cases.)
139Muhammed Al-Mulhem Visual Languages
140Muhammed Al-Mulhem Visual Languages
Control Flow (Cont.)
• In this simple example, the same annotation - a check mark in an otherwise empty rectangle - is used.
• The semantics of this annotation are: “If this operation succeeds, then go to the next case.” The check mark is the iconic representation of success, and the empty rectangle represents the ‘go to the next case’ notion. If the check mark were replaced by an ‘x’, then the semantics would have been: “If this operation fails, then go to the next case”.
141Muhammed Al-Mulhem Visual Languages
Control Flow (Cont.)
• In addition to the otherwise empty rectangle, there are four other possibilities, and the five different semantics of control annotations are shown together in the next Figure.
• It is a run-time error and a compile-time warning to have a next-case control annotation in a location where it cannot execute, for example, in the last case of a method.
142Muhammed Al-Mulhem Visual Languages
143Muhammed Al-Mulhem Visual Languages
144Muhammed Al-Mulhem Visual Languages
145Muhammed Al-Mulhem Visual Languages
146Muhammed Al-Mulhem Visual Languages
147Muhammed Al-Mulhem Visual Languages
148Muhammed Al-Mulhem Visual Languages
149Muhammed Al-Mulhem Visual Languages
150Muhammed Al-Mulhem Visual Languages
151Muhammed Al-Mulhem Visual Languages
Classification of Visual Programming
• Looking at the recent work reported in the literature, we see visual programming progressing in number of directions.
1) Visual Environments for different applications.
2) Visual Languages.
3) Theory of Visual Languages.
152Muhammed Al-Mulhem Visual Languages
1) Visualization of Data
• Typically, the information or data is stored internally in traditional databases, but expressed in graphical form and presented to the user in a special framework.
• Users can traverse the graphical surface or zoom into it to obtain greater detail with a joystick or a pointing device.
153Muhammed Al-Mulhem Visual Languages
Visualization of Data (Cont.)
• The user can use the mouse to answer many questions without the need of a keyboard.
• These systems are devoted primarily to using “direct manipulation” as a means of information retrieval, using a graphical view of a database for visualization of the information retrieved.
154Muhammed Al-Mulhem Visual Languages
Example
• A visual environment can be built for the retrieval of information from a database of ships.
• Each ship will be represented by an icon.
• Icon shape, color and size represent type, status, and size of the ship.
155Muhammed Al-Mulhem Visual Languages
2) Visualization of Programs
• The goal of this is to provide programmers and users with an understanding of :
– What the program can do
– How they work
– Why they work
– What are the effects
156Muhammed Al-Mulhem Visual Languages
This is beneficial for
• beginners learning to program.
• professionals dealing with various aspects of programming tasks:
– Designing,
– Debugging,
– Testing, and
– Modification.
157Muhammed Al-Mulhem Visual Languages
BALSA
• BALSA ( Brown Algorithm Simulator and Animator ) developed by Sedgewick and his colleages in Brown University. [ Sedgwick, 1983 ]
• It enables users :– to control the speed of an animated algorithm
– to decide which view to look at.
– to specify the input data to be processed.
158Muhammed Al-Mulhem Visual Languages
• BALSA include the following animated algorithms:
• Mathematical algorithms such as– Euclid’s GCD algorithm.
– Random numbers.
– Curve fitting.
• Sorting algorithms such as– Insertion sort.
– Quick sort.
– Merge sort.
– External sort.
159Muhammed Al-Mulhem Visual Languages
• Searching algorithms such as– Sequential search.
– Balanced trees.
– Hashing.
– Radix searching.
• Selecting an icon from the iconic table with a mouse causes a 10 - 15 minute dynamic simulation of the selected topic to be run, with pauses at key images, after which the user can interact with the algorithms and images.
160Muhammed Al-Mulhem Visual Languages
161Muhammed Al-Mulhem Visual Languages
3) Visualization of Software Design• It is very important throughout the software life
cycle to understand:– specifications
– design
– system structure
– dependencies among data and components
– etc.
• This observation, together with the success of using graphical techniques has led to the development of a visual environment for software life cycle.
162Muhammed Al-Mulhem Visual Languages
The PEGASYS• The main purpose of PegaSys is to provide a
visual environment for the development and explanation of large program designs (as opposed to detailed algorithms and data structures in a program)
• PegaSys supports the specification and analysis of data and control dependencies among the components of large programs.
163Muhammed Al-Mulhem Visual Languages
• A program design is described in PegaSys by a hierarchy of interrelated pictures.
• Icons denote predefined or user-defined concepts about dependencies in programs.
164Muhammed Al-Mulhem Visual Languages
• The predefined primitives denote:
– objects (such as subprograms, modules, processes, and data structures),
– data dependencies (involving the declaration, manipulation, and sharing of data objects), and
– control dependencies (dealing with asynchronous and synchronous activities).
• A PegaSys user can define new concepts in terms of the primitives.
165Muhammed Al-Mulhem Visual Languages
Example
• A network of 4 hosts can be represented in PegaSys as follows: –Each of the four hosts in the network is
indicated by an ellipse,
–the communication line indicated by a dashed rectangle.
–a packet of data indicated by a label on arcs.
166Muhammed Al-Mulhem Visual Languages
• Dependencies among hosts, packets, and the line are described by the write relation (denoted by the letter W on arrows) and the read relation (denoted by R)
The system says that:• the broadcast network consists of four hosts that
communicate by means of a line.
• More precisely, processes named Host1,... Host4 write values of type pkt into a module called Line and read values of the same type from the Line module.
167Muhammed Al-Mulhem Visual Languages
168Muhammed Al-Mulhem Visual Languages
Visualization of Parallel Systems
• A number of display facilities have been associated with:
» debuggers
» performance evaluation tools
» program visualization systems
169Muhammed Al-Mulhem Visual Languages
Debugger displays
Debugger displays attempt to provide some view of program state such as:
• the pattern of access to shared memory
• the interprocessor communication of a particular distributed memory architecture
• the order in which subroutines are called
170Muhammed Al-Mulhem Visual Languages
Displays for Performance Visualization Tools
Performance visualization tools generally provide a graphical representation of standard metrics such as:
• Processor utilization
• Communication load
171Muhammed Al-Mulhem Visual Languages
Displays for Program Visualization Systems
Program visualization systems provide highly application specific views of:
• the program's data structures
• the operations which update these data structures
• or some more abstract representation of the computation and its progress.
172Muhammed Al-Mulhem Visual Languages
Program Graphs
Many systems display graphs in which:
• the vertices represent program entities and
• the arcs represent call relations or temporal orderings, similar to the graph shown in Fig. 1.
173Muhammed Al-Mulhem Visual Languages
Fig. 1. An animated call graphMAIN
SELECT
PRUNE EXPAND UPDATE
PROCESS
COUNT
BROADCAST
174Muhammed Al-Mulhem Visual Languages
Concurrency of the Computation
• A number of systems use a graph to represent the concurrency of the computation.
1) The concurrency map
• The concurrency map displays process histories as event streams on a time grid.
175Muhammed Al-Mulhem Visual Languages
• Each column of the display represents the sequential stream of events for a single process.
• Each row of the grid represents an interval of time during which the events in different columns may occur concurrently.
• Every event in one row must occur before any event in the next row.
176Muhammed Al-Mulhem Visual Languages
Communication Graphs
• A number of systems present displays that represent communication among processors through the use of boxes, arrows, and lines.
– Boxes represent processors,
– Lines represent connections. and
– Arrows represent communication events, as shown in Fig. 2.
177Muhammed Al-Mulhem Visual Languages
Fig. 2: Communication Graph
P6P7
P3 P2
P4 P5
P0 P1
178Muhammed Al-Mulhem Visual Languages
VPL
• Here we will show some Visual Programming Languages.
179Muhammed Al-Mulhem Visual Languages
BLOX
• The basic elements in BLOX system are icons similar in shape to jigsaw puzzle pieces.
• Programs are composed by
1) Juxtaposing icons in appropriate ways, so that neighbors interlock.
2) Encapsulating substructure
180Muhammed Al-Mulhem Visual Languages
Pascal-BLOX
WHILE
• The “lock and key” metaphor enforces proper syntax.
181Muhammed Al-Mulhem Visual Languages
Programs in Pascal - BLOX
• It uses top-down program design.
• The code segments could be encapsulated in the appropriate tiles. This include codes corresponding to:
– the alternative branches
– loop bodies
– Boolean expressions associated with IF and WHILE statements.
182Muhammed Al-Mulhem Visual Languages
ExampleBegin
S1;If not I1 Then
BeginS2;S3;
EndElse
While L1 DoBegin
If I2 Then S4Else S5;
S6;End;
While L2 Do S7;S8;
End.
183Muhammed Al-Mulhem Visual Languages
Pascal - BLOX Program
184Muhammed Al-Mulhem Visual Languages
Advantages
• Top-down specification of programs
• Extension of a familiar metaphors from children's toys.
• Automatic elimination of the most source of possible syntax errors in user programs, by the use of the “Lock and Key” metaphor.
• The representation can be applied to diverse and varied activities in a uniform manner.
185Muhammed Al-Mulhem Visual Languages
Our VPLs
• Our efforts to design and implement visual programming languages include:
1) DataLab (with T. Lewis, and H. Kim, 1989)
2) VISO: A Visual Languages for Concurrent Programming (with S. Ali, 1994)
186Muhammed Al-Mulhem Visual Languages
VISO
• VISO is a visual programming language for concurrent programming.
• It has a graphical syntax based on the language OCCAM.
• It uses a modular approach of visual programming
187Muhammed Al-Mulhem Visual Languages
188Muhammed Al-Mulhem Visual Languages
189Muhammed Al-Mulhem Visual Languages
DataLab
• DataLab is a general-purpose system for the specification and synthesis of abstract data types (ADTs).
• DataLab uses a combination of graphical and textual forms as a specification model for ADTs.
• An imperative semantics is used to automatically generate an encapsulated executable code (Pascal modules) from such a specification.
190Muhammed Al-Mulhem Visual Languages
Contribution
• DataLab extends earlier work by
1) allowing data structures to be created and displayed in their classical notation,
2) generating encapsulated imperative code (Pascal), and
3) incorporating composition of simple structures into more complex structures.
191Muhammed Al-Mulhem Visual Languages
Example - Linked List• The first step is to define the interface part
unit LINKED_LIST;
interface
type
LL_list = ^LL_node;
LL_node = record
data : string;
next : LL_list;
end;
procedure LL_insert(var list : LL_list; item : string);
implementation
end.
192Muhammed Al-Mulhem Visual Languages
• Next, the procedure "LL_insert" is specified by two Conditional transformations
0
node^.data := item;
list
listlist^
list^
1
2:list
node^ 4
3
9:next
8
10:list
11
1
node 5 6:node
7
193Muhammed Al-Mulhem Visual Languages
0
2:list 3 1
8:next
7
list^.data := item;
list
list
list^
4
5
6:list
9
2
194Muhammed Al-Mulhem Visual Languages
What is next for VPLs?
• More effective use of color and sound.
• 3-D instead of 2-D graphics.
• Animated graphics.
• Languages for concurrent and parallel programming.