I've done my share of porting 'C' code,
cursing the idiot who assumed
all of the "Unix-isms" in the original code.
Idiot? Perhaps the code was just written for Unix. I've written
plenty of code with no attempt to make it portable to non-Unix, or
non-SPARC, or non-VMS, or non-32-bit, or non-whatever. Does that make
me an idiot? Well, perhaps, if such portability should have been
designed in, but absent such a reason, I don't think so.
The notion of a portable C is ridiculous.
Not for suitable values of "portable". I really can't see it as a
fault of C if code not written to be portable to non-Unix is not
portable to non-Unix. (It may be a fault of the programmer, if porting
attempts to non-Unix were reasonably to be expected, but even then it
wouldn't be the fault of the *language*.)
C co-evolved with Unix. I don't see this as a failing of the language;
I see it as a failing of people who not only try to use C on non-Unix
but then proceed to blame C for the inevitable mismatch.
Even a simple statement like:
char c[100], *pc;
pc = &(c[52]);
can be entirely foreign to a machine's
architecture. What if the
machine's not character-addressable? What do the contents of pc mean
at that point?
Whatever is necessary to refer to c[52]. By definition.
If char is smaller than the machine's addressing granularity, a
pointer-to-char is - must be! - more complicated than a simple memory
address. Figuring out how to handle/avoid such things is part of
building a C implementation for an architecture.
On the other hand, if you want a nice portable
language, FORTRAN is
pretty darned close to universal.
Portable, well, perhaps, if you write in an old enough dialect.
(Though, again, "portable" immediately raises the question "to
what?".)
Nice? Not really, unless you're doing heavy numerical code. That's
what FORTRAN was designed for and what it shines at. Like most
languages, it fares rather badly outside its design domain.
But to this observer, C represents a step backwards in
language
development. If it hadn't been for microcomputers, would we even be
talking about C for applications code today?
Quite possibly, provided you don't drop Unix in your counterfactual too.
/~\ The ASCII der Mouse
\ / Ribbon Campaign
X Against HTML mouse at rodents.montreal.qc.ca
/ \ Email! 7D C8 61 52 5D E7 2D 39 4E F1 31 3E E8 B3 27 4B