Meta-programming important for Psychology of Programming
Massimo Dentico
m.dentico@teseo.it
Thu, 04 May 2000 21:42:25 +0200
Excerpt from "Getting Rid of the Single Notation Paradigm with
Multiple Views" (emphasis mine):
- http://www.ppig.org/papers/11th-sajaniemi.html
------------------------------------------------------------------
Introduction
[...]
The normal program text representation is all that a compiler
needs but humans need multiple representations, or views, of the
same program to support the construction of different aspects of
mental representations.
[...]
The method proposed in this paper is a step towards the direction
proposed by Green. We give programmers an opportunity to utilize
multiple editable views of the same program. In other words, the
system described in this paper is capable of representing programs
in various notations supporting various types of information.
Moreover, programs can be edited through most views enabling
programmers not only to extract information in multiple notations
but also to fully work in these notations. As a consequence, it
becomes almost impossible to say which of the notations is the
'right' one, i.e., obeys the syntax of the programming language as
understood by the compiler. Thus, ***the role of the programming
language changes from a syntax definition to a more semantic
description.***
------------------------------------------------------------------
A leit-motiv in Tunes: syntaxes (notations) should be constructed
dynamically, when necessary, and they should not be fixed once for
all.
However, from the point of view of the compiler (thus meta-
programming), it is not true that "The normal program text
representation is all that a compiler needs ...": different views,
or intermediate representations (AST, DAG, RTL, ...), are
necessary even to the compiler in order to complete its task.
------------------------------------------------------------------
Views in Action
We have implemented a program editor framework, VinEd (Sajaniemi &
Ikonen, 1998), that is capable of showing multiple editable views
of programs. An optimal set of views is, however, beyond current
knowledge of program representations and program comprehension
process. It may even be impossible to define any representation
that every individual can call sensible, and views probably need
to be defined according to the environment and background of the
programmer (Shneiderman & al., 1986). This problem is solved in
VinEd by ***letting programmers define their own views and add
them to the system. As programmers are programming experts they
are able, and supposedly also keen, to create supporting programs
that construct views that they feel to be helpful for their tasks.
VinEd is shipped with some ready-made views for some programming
languages but users are supposed to add their own views.***
In VinEd, a view can be any text obtained by applying some
***transformer program*** to the original file. As the output of a
transformer is text (and not a graphical representation),
programming new transformers is relatively easy. If a reverse
transforming program is also given, files can be edited (and not
just browsed) in the view. For example, the list of all function
names in a program facilitates comprehension of the program by
showing structured information and the underlying design
(Shneiderman & al., 1986). ***A Pascal programmer can easily make
a short program (using a single line UNIX shell script consisting
of a call of the grep command with the result piped to a sed
command) that makes such a list for his or her own programs
(though the solution in the general case is somewhat more
tedious).*** Thus he or she can see the list in a view window with
the program text in another window. Even the reverse transforming
is simple in this case and hence the programmer can change the
name of a function in the function name list, and the system will
automatically apply the reverse filtering and thus change all
occurrences of that name in the program. Views are updated
automatically so that they reflect all the time editing
operations made so far.
[...]
------------------------------------------------------------------
It is obvious that these transformer programs, which construct
views of the program in examination, are meta-programs (programs
that manipulate and/or produce programs) and, contrary to the
example described in the text, the meta-language could be the same
of the target language (providing the suitable infrastructure). As
a side note, Domain Specific Languages (DSLs) are a kind of "view"
(notation, syntax).
Moreover it is desirable that the development environment is open
(open implementation): many parts (if not all) of the programming
environment are available to the application programmer like, for
example, in Smalltalk, Forth or Pliant.
This paper shows the importance of meta-programming even from the
psychological-cognitive point of view.
The home page of Psychology of Programming Interest Group (PPIG):
- http://www.ppig.org/
--
Massimo Dentico