Dear all,
The discussion is at some points coming perilously close to
one of my favourite subjects -- what the "intended behaviour" of
a program is -- so I can't resist jumping in (especially since
it's the summer and I have time for such things again).
I assure you that I will get back to the question of
understanding the hello-world program by the end of the message.
I have often argued, probably misusing precise
psychological terms left and right, that at bottom we use
computers in general, and write and use specific programs in
particular, in order to accomplish one or more of three things:
(a) taking some mechanical physical action, (b) changing the
mental states of the people who interact with them, and/or (c)
changing the emotional states of the people who interact with
them. I include (c) mostly to cover such things as video games,
which are not so typical; an airport check-in counter may be a
more typical example.
When I arrive at the counter, I present the clerk my ticket
(say, one of these new electronic tickets), and some
identification. The clerk types in my name and possibly other
information into the computer. When the screen displays the
system's output, the clerk's mental state changes from one in
which she is not sure whether I have a right to get on the
aircraft, to one in which she is sufficiently convinced that I
do have that right that she prints a boarding pass. Her mental
state may change for any number of reasons, including that the
computer has often been right in the past; that her trainers
have assured her that the computer is almost always right in
that respect; that she has invoked a mental template (whatever
that means) of someone buying a ticket, someone else typing my
information into a computer, that information being stored, and
her recalling that information; and so on. In this respect, the
clerk is behaving not much differently from when she looks at my
ID, because she draws on the same kinds of past experience to
sufficiently convince her that I really am the person I say I
am (pace tiny doubts regarding authenticity of ID, similar to the
(hopefully) tiny doubts she may have regarding the correctness
of the computer system). Hence she interacts with the computer
again and gets it to take the physical action of printing off a
boarding pass. (The boarding pass may then have secondary
effects on the people that see it, but let's leave that for now).
Now for the hello-world program. I would contend that we
intend that program, and most such programs, to produce the
mental state in which I (or some other user) am convinced that I
have been able to compile and run a small program on the
platform on which I have been working. It is generally
successful in producing such a mental state because, however it
does it, it will produce the rather unusual text "Hello world"
somewhere on the computer screen, in a location different from
where I just typed it in, right after I have issued the commands
to compile and execute the program; because I have not gotten
the impression that anything went wrong along the way; and
because my past experience indicates that when such text appears
on the screen in such a location just after issuing a command to
execute a program, it is almost certainly attributable to the
program I have just asked the system to execute.
I would contend that we cannot separate the question of
whether we understand a piece of code from our knowledge of its
intended effect. The more we know about the intended effect of
a program, the more of a guide we will have to understanding the
code itself. This is one reason why comments and variable and
function names are so important: they allow us to link the
entities in the code with the intended effect of the program,
and this gives us clues to understanding the purpose of the
individual statements, blocks, and function definitions, and
thus the whole program. In the absence of such clues (e.g. no
comments and randomly-generated variable names), I am
hard-pressed to say that I understand any but the most trivial
programs, even knowing their intended effects.
I would therefore interpret the question "Do you understand
program X?", as it would normally be asked, to mean something
like, "Given the source code of program X, and given your past
experience, your knowledge about the programming language, and
your impression of the intended effect of the program, do you
believe that given more complete knowledge of the intended
effect of the program, you would be able to decide whether the
program would have its intended effect?"
I would therefore contend that to the question "Do you
understand the hello-world program?", all C programmers
(averrals to the contrary notwithstanding) should reasonably
answer "yes". We (C programmers) have enough of an idea of the
intended effect of the program, and enough knowledge about the
language, that we are confident enough that (for instance) the
question of whether the program produces one line of output or
pops up a window is irrelevant. If the text in the string were
not "Hello world" but rather "This is text appearing in a
separate window from the run command", then we might actually
doubt the intended effect of the program; this might lead to our
realizing that we don't know whether the string is going to pop
up in a separate window or not, and this in turn might lead us
to the conclusion that we don't really understand the program.
Because the text is "Hello world", we should be reasonably
certain that we understand the intended effect. That, combined
with our knowledge of C, should allow us to state that we
understand the program. (Actually, any text unconnected to
specifics of running programs would do, but it certainly helps
that the words "Hello world" suggest a kind of initial
communication between some entity and whoever might be
observing, regardless of whether we have seen the example before
or not.)
cheers
--Jamie.
- Automatic footer for [EMAIL PROTECTED] ----------------------------------
To unsubscribe from this list, mail [EMAIL PROTECTED] unsubscribe discuss
To join the announcements list, mail [EMAIL PROTECTED] subscribe announce
To receive a help file, mail [EMAIL PROTECTED] help
This list is archived at http://www.mail-archive.com/discuss%40ppig.org/
If you have any problems or questions, please mail [EMAIL PROTECTED]