At 02:26 PM 5/8/99 -0700, EKR wrote:
>
>If programmers though this way, they'd make an attempt to make their
>source code readable, but by and large they don't.
Um, are you talking your can't-yet-grow-a-moustache teenage
"programmer" or an experienced person?
Moreover, the
>code (especially C code) is littered with constructs which serve
>no communicative purpose but solely tell the computer what to do.
Wrong. My mental model, when understanding code, involves what
the compiler does when it reads what I read. "int i" causes
me, and a compiler, to model a bit of (possibly implicitly initialized)
state. If its Java I'm reading, there are assumptions about
how it goes away, too.
When you read any other recipe, similar world-assumptions are
used. When making a cake, turn on the mixer for a minute. This
implies things: that the blades will spin if its not broken, plugged in,
and the power grid is working. No cookbook says this, but it is essential
to understand the process being described.
>(Memory management comes to mind as a prime example. The only
>purpose of calling free() is to release memory. It serves no
>expository purpose.
It does! It tells the reader to forget about a thing,
and to adjust the reader's estimation of max resource usage.
This is clearly shown by the fact that
>garbage collected languages do without it.)
>
>> Have you ever modified a program written by someone else? What's your
first
>> step? You read the program, to find out what it does. You don't read the
>> massive paper document that describes what the program does and how ..
>> because there is no such document. You don't read the comments in the
code
>> .. because there are lamentably few comments. Therefore, you read the
>> source code.
>Because it's your only choice.
>
>> My first system programming professor drove this point home
>> to us -- noting that even solitary projects require communication to some
>> "other" programmer: namely ourselves at a later date when we've forgotten
>> what was in our minds at the time we started writing the code.
>The very fact that you have to be taught this should make clear
>that the actual purpose of code is instructing machines, not people.
>People hardly ever forget that the purpose of writing text is
>communication.
>
>> QED
>Hardly.
>
>-Ekr
Eric I hope you're just miffed about reading some lame
code written by some quasi-literate who can't touchtype.
Good code is more readable than legal prose to a non-lawyer.
The snuffle excerpt was not a great example of this. "l" is
not a great function name.