Sprach EKR <[EMAIL PROTECTED]>:
> Carl Ellison <[EMAIL PROTECTED]> writes:
> > Source code is human speech, for human-to-human communication. It has a
> > side-effect of being compilable into machine code, but it is in a human
> > language and is intended for human communication.
> This strikes me as patently false.
>
> If programmers though this way, they'd make an attempt to make their
> source code readable, but by and large they don't. Moreover, the
> code (especially C code) is littered with constructs which serve
> no communicative purpose but solely tell the computer what to do.
> (Memory management comes to mind as a prime example. The only
> purpose of calling free() is to release memory. It serves no
> expository purpose. This is clearly shown by the fact that
> garbage collected languages do without it.)
Ummm. No.
As a trivial example, if I am attempting to communicate about memory
management issues, my use of free() might become the primary carrier of
meaning in the code.
In a much more common example, an ongoing question with third party libraries
is "who allocates the memory buffers used by the function" and "who frees the
memory that's allocated by the function". Suitable uses of malloc() and
free() in code fragments (or their absence) precisely communicates the answers
to both of those questions.
In fact, I will go further than this: every feature of a program, from the
actual functional elements to whitespace and punctuation has the potential
to carry communication, even when those are seemingly arranged in such a
way as to hinder communication.
As every professional programmer knows, your use of whitespace bears redundant
syntactic meaning for people who use the same whitespace style.
Obscure code constructs are a very good way to communicate efficient coding
techniques (which is to say: techniques by which the programmer can control
the output of the compiler's optimizer), or simply ways to describe the powers
and limitations of the language. A perfect example of this last is the
Obfuscated C Code contests: surely no one is about to claim that the primary
purpose of that code is to control a computer. No, the primary purpose is
to communicate the message "I'm mucho more studly coder d00d than U" to the
other contestants.
In fact, code snippets are such a good way to communicate, that for 7
years, I would interview job candidates merely by showing them a
particularly subtle 4 line 8086 assembly code fragment and asking
them what function it performed, and to reason out loud as they tried
to figure it out. (I also use the fragment to show that optimizers will
never be as good as human programmers).
Last, don't try any "if programmers thought this way..." statements: I'm
a programmer, and I think this way. Therefore, there is at least one
programmer who does. There's no "if" involved.
--
Jon Paul Nollmann ne' Darren Senn [EMAIL PROTECTED]
Unsolicited commercial email will be archived at $1/byte/day.
Congratulations FBI men: Hoover would be proud of you