On 8/2/07, Brent Hilpert <hilpert at cs.ubc.ca> wrote:
> On 1 Aug 2007 at 20:56, dwight elvey wrote:
> > C doesn't fit well onto any of the processors that I've seen lately.
> > It is always sub-optimal.
C works pretty well on my PDP-11 ;-) Of course, it's been long
pointed out that C is just PDP-11 assembly shorthand - having waded
through the guts of C-compiler output on a few architectures, I
completely agree that's how it started out.
C on a 68K is nice, too, but for those that know the PDP-11 and 68K
architecture, that's no surprise. C on a VAX is also nice.
Can't say I've dig deeply enough on any processor architecture newer
than about 1978, so perhaps that merely reinforces your statement.
Apropros of not much, but to ensure this is on-topic,
I never hear B or BCPL
mentioned, the ancestors of C, and even 'closer to the machine'. I'm not
sure
how many C programmers these days even know it has such ancestors.
Amiga programmers know about BCPL. AmigaDOS, nee Tripos, is riddled
with "BPTR"s - take a regular pointer to anything, enforce long-word
alignment, and, as a consequence, observe that the bottom two bits are
always 00. Now... since the pointers your compiler generates always
end in two zeros, right-shift your pointers twice before saving them
in a variable. This has the intended benefit of allowing you to store
pointers to objects in a 256K (18-bit) environment in 16-bit
variables. It has the unintended consequence of messing with the
heads of assembler and C programmers. You have to remember to
double-left-shift BPTRs before dereferencing them, and to
double-right-shift them when you are done incrementing them and want
to store them for later use by a system call or whatever. This
routinely leads to pointer bugs when writing AmigaDOS programs,
especially among the unwary.
So I've never programmed in B or BCPL, but I spent years dealing with
the downstream effects of them. So did every Amiga C and assembler
programmer 20 years ago.
Other than the on Amiga, though, I suspect to most, B and BCPL are
footnotes in K&R.
-ethan